ft (placeholder): player attacking anim

This commit is contained in:
Djairo Hougee 2026-01-17 14:47:16 +01:00
parent 03117b77fb
commit c0f5dd4628
4 changed files with 56 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 KiB

View File

@ -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

View File

@ -6,6 +6,7 @@ extends CharacterBody2D
@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
@ -32,6 +33,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,7 +49,7 @@ 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
@ -53,6 +57,7 @@ func _on_attack_timeout() -> void:
func _on_cooldown_timeout() -> void: func _on_cooldown_timeout() -> void:
can_attack = true can_attack = true
sprite.play("default")
func _on_attack_hit(body: Node2D) -> void: func _on_attack_hit(body: Node2D) -> void:
if body.is_in_group("prey") or body.is_in_group("predators"): if body.is_in_group("prey") or body.is_in_group("predators"):

View File

@ -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,
@ -41,7 +50,6 @@ shape = SubResource("RectangleShape2D_en8op")
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")