Compare commits
2 Commits
03117b77fb
...
0b9b1e75d4
| Author | SHA1 | Date |
|---|---|---|
|
|
0b9b1e75d4 | |
|
|
c0f5dd4628 |
Binary file not shown.
|
After Width: | Height: | Size: 887 KiB |
|
|
@ -0,0 +1,40 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://boknmstvkc0a2"
|
||||||
|
path="res://.godot/imported/player-sprite-placeholder-attacking-crop.png-7a6a3f2b68f208c74f7cac8cb16cfc5e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://molecular/assets/player-sprite-placeholder-attacking-crop.png"
|
||||||
|
dest_files=["res://.godot/imported/player-sprite-placeholder-attacking-crop.png-7a6a3f2b68f208c74f7cac8cb16cfc5e.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
@export var attack_duration = 0.12 # TODO: finetune
|
@export var attack_duration = 0.2 # TODO: finetune
|
||||||
@export var attack_cooldown_duration = 0.4
|
@export var attack_cooldown_duration = 0.4
|
||||||
|
|
||||||
@onready var attack_area: Area2D = $AttackArea
|
@onready var attack_area: Area2D = $AttackArea
|
||||||
@onready var attack_timer: Timer = $AttackTimer
|
@onready var attack_timer: Timer = $AttackTimer
|
||||||
@onready var attack_cooldown_timer: Timer = $AttackCooldownTimer
|
@onready var attack_cooldown_timer: Timer = $AttackCooldownTimer
|
||||||
|
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||||
|
|
||||||
@export var speed = 200
|
@export var speed = 200
|
||||||
var damage = 10
|
var damage = 10
|
||||||
|
|
@ -19,6 +20,8 @@ func _ready() -> void:
|
||||||
attack_timer.wait_time = attack_duration
|
attack_timer.wait_time = attack_duration
|
||||||
attack_cooldown_timer.wait_time = attack_cooldown_duration
|
attack_cooldown_timer.wait_time = attack_cooldown_duration
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
if Input.is_action_pressed("move_right"):
|
if Input.is_action_pressed("move_right"):
|
||||||
|
|
@ -32,6 +35,9 @@ func _process(delta):
|
||||||
if Input.is_action_pressed("try_attack"):
|
if Input.is_action_pressed("try_attack"):
|
||||||
try_attack()
|
try_attack()
|
||||||
|
|
||||||
|
if not velocity.is_zero_approx():
|
||||||
|
look_at(velocity * 1000000) # FIXME: ideally we look_at a point at infinity
|
||||||
|
# or rotate the player some other way
|
||||||
move_and_collide(speed * velocity * delta)
|
move_and_collide(speed * velocity * delta)
|
||||||
#position += speed * velocity * delta
|
#position += speed * velocity * delta
|
||||||
position = GameManager.get_boundaried_position(position)
|
position = GameManager.get_boundaried_position(position)
|
||||||
|
|
@ -45,19 +51,25 @@ func attack() -> void:
|
||||||
can_attack = false
|
can_attack = false
|
||||||
attack_area.monitoring = true
|
attack_area.monitoring = true
|
||||||
attack_timer.start()
|
attack_timer.start()
|
||||||
# TODO: attack animation+sound+etc
|
sprite.play("attacking")
|
||||||
|
|
||||||
func _on_attack_timeout() -> void:
|
func _on_attack_timeout() -> void:
|
||||||
attack_area.monitoring = false
|
attack_area.monitoring = false
|
||||||
|
sprite.play("default")
|
||||||
attack_cooldown_timer.start()
|
attack_cooldown_timer.start()
|
||||||
|
|
||||||
func _on_cooldown_timeout() -> void:
|
func _on_cooldown_timeout() -> void:
|
||||||
can_attack = true
|
can_attack = true
|
||||||
|
|
||||||
func _on_attack_hit(body: Node2D) -> void:
|
func _on_attack_hit(body: Node2D) -> void:
|
||||||
|
var hit_hittable = false
|
||||||
if body.is_in_group("prey") or body.is_in_group("predators"):
|
if body.is_in_group("prey") or body.is_in_group("predators"):
|
||||||
if body.has_method("handle_damage"):
|
if body.has_method("handle_damage"):
|
||||||
body.handle_damage(damage)
|
body.handle_damage(damage)
|
||||||
|
hit_hittable = true
|
||||||
elif body.is_in_group("resources"):
|
elif body.is_in_group("resources"):
|
||||||
pass
|
pass
|
||||||
|
if hit_hittable:
|
||||||
|
await get_tree().create_timer(0.2).timeout
|
||||||
|
sprite.play("default")
|
||||||
# TODO: resource handling logic
|
# TODO: resource handling logic
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,21 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://dxluckxdkpv4f"]
|
[gd_scene load_steps=7 format=3 uid="uid://dxluckxdkpv4f"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://di7eglnrnqm6i" path="res://molecular/molecular_player.gd" id="1_0ix7k"]
|
[ext_resource type="Script" uid="uid://di7eglnrnqm6i" path="res://molecular/molecular_player.gd" id="1_0ix7k"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://boknmstvkc0a2" path="res://molecular/assets/player-sprite-placeholder-attacking-crop.png" id="2_5hxmy"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cxwvga07sm3yl" path="res://molecular/assets/player-sprite-placeholder-crop.png" id="2_en8op"]
|
[ext_resource type="Texture2D" uid="uid://cxwvga07sm3yl" path="res://molecular/assets/player-sprite-placeholder-crop.png" id="2_en8op"]
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_onrkg"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_onrkg"]
|
||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_5hxmy")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"attacking",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 5.0,
|
||||||
"texture": ExtResource("2_en8op")
|
"texture": ExtResource("2_en8op")
|
||||||
}],
|
}],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
|
|
@ -14,8 +23,8 @@ animations = [{
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_en8op"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_5hxmy"]
|
||||||
size = Vector2(765.4969, 706.5864)
|
radius = 378.18
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_4flbx"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_4flbx"]
|
||||||
radius = 191.95984
|
radius = 191.95984
|
||||||
|
|
@ -36,12 +45,11 @@ rotation = -1.5732701
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="AttackArea"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="AttackArea"]
|
||||||
position = Vector2(29.579561, 730.73236)
|
position = Vector2(41.029465, 288.86832)
|
||||||
shape = SubResource("RectangleShape2D_en8op")
|
shape = SubResource("CircleShape2D_5hxmy")
|
||||||
debug_color = Color(0.80813414, 0.3957308, 0.3356335, 0.41960785)
|
debug_color = Color(0.80813414, 0.3957308, 0.3356335, 0.41960785)
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=["player"]]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=["player"]]
|
||||||
position = Vector2(0, 56)
|
|
||||||
rotation = -1.5732701
|
rotation = -1.5732701
|
||||||
shape = SubResource("CapsuleShape2D_4flbx")
|
shape = SubResource("CapsuleShape2D_4flbx")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,10 @@ func die() -> void:
|
||||||
super.die()
|
super.die()
|
||||||
|
|
||||||
func become_injured() -> void:
|
func become_injured() -> void:
|
||||||
sprite.animation = "Injured"
|
sprite.play("Injured")
|
||||||
mirrorSprite1.animation = "Injured"
|
mirrorSprite1.play("Injured")
|
||||||
mirrorSprite2.animation = "Injured"
|
mirrorSprite2.play("Injured")
|
||||||
mirrorSprite3.animation = "Injured"
|
mirrorSprite3.play("Injured")
|
||||||
sprite.play()
|
|
||||||
|
|
||||||
# Mirroring table:
|
# Mirroring table:
|
||||||
# |---|---|---|---|
|
# |---|---|---|---|
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,3 @@ maxHealth = 20
|
||||||
scale = Vector2(0.1, 0.1)
|
scale = Vector2(0.1, 0.1)
|
||||||
sprite_frames = SubResource("SpriteFrames_66x8p")
|
sprite_frames = SubResource("SpriteFrames_66x8p")
|
||||||
animation = &"Dying"
|
animation = &"Dying"
|
||||||
frame_progress = 0.60472965
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue