Added death animation

This commit is contained in:
2026-01-07 22:59:14 +03:00
parent 85f808b733
commit 1ac74e7793
4 changed files with 202 additions and 94 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ script = ExtResource("1_2wrno")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
material = SubResource("ShaderMaterial_vecdo") material = SubResource("ShaderMaterial_vecdo")
sprite_frames = SubResource("SpriteFrames_2wrno") sprite_frames = SubResource("SpriteFrames_2wrno")
animation = &"walk_right" animation = &"idle_front"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 2) position = Vector2(0, 2)
+7 -2
View File
@@ -16,6 +16,7 @@ const ANIMATION_FALL_DOWN_RIGHT = "fall_down_right"
const ANIMATION_FALL_UP = "fall_up" const ANIMATION_FALL_UP = "fall_up"
const ANIMATION_FALL_UP_LEFT = "fall_up_left" const ANIMATION_FALL_UP_LEFT = "fall_up_left"
const ANIMATION_FALL_UP_RIGHT = "fall_up_right" const ANIMATION_FALL_UP_RIGHT = "fall_up_right"
const ANIMATION_DEATH = "death"
const LOOK_AROUND_CHANCE = 25 const LOOK_AROUND_CHANCE = 25
const PICKUP_OFFSET = 16.0 const PICKUP_OFFSET = 16.0
@@ -56,8 +57,9 @@ func _physics_process(delta: float) -> void:
for i in range(get_slide_collision_count()): for i in range(get_slide_collision_count()):
var collision := get_slide_collision(i) var collision := get_slide_collision(i)
if collision.get_collider() is AbstractEnemy: if collision.get_collider() is AbstractEnemy:
queue_free() get_tree().paused = true
dead.emit() sprite.process_mode = Node.PROCESS_MODE_ALWAYS
sprite.play(ANIMATION_DEATH)
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
@@ -127,6 +129,9 @@ func _on_animation_finished() -> void:
match sprite.animation: match sprite.animation:
ANIMATION_LOOK_AROUND_1, ANIMATION_LOOK_AROUND_2: ANIMATION_LOOK_AROUND_1, ANIMATION_LOOK_AROUND_2:
sprite.play(ANIMATION_IDLE) sprite.play(ANIMATION_IDLE)
ANIMATION_DEATH:
dead.emit()
queue_free()
func _on_animation_looped() -> void: func _on_animation_looped() -> void:
+192 -89
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=39 format=3 uid="uid://dtcad8tdx78tg"] [gd_scene load_steps=53 format=3 uid="uid://dtcad8tdx78tg"]
[ext_resource type="Script" uid="uid://bb8kc32sggrn2" path="res://game/characters/player.gd" id="1_xln5q"] [ext_resource type="Script" uid="uid://bb8kc32sggrn2" path="res://game/characters/player.gd" id="1_xln5q"]
[ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="2_i05k5"] [ext_resource type="Shader" uid="uid://lqq1mg6l1qqe" path="res://game/shaders/black_n_white.gdshader" id="2_i05k5"]
@@ -15,29 +15,85 @@ shader_parameter/speed = 5.0
shader_parameter/intensity = 1.0 shader_parameter/intensity = 1.0
shader_parameter/scale = 20.0 shader_parameter/scale = 20.0
[sub_resource type="AtlasTexture" id="AtlasTexture_457no"] [sub_resource type="AtlasTexture" id="AtlasTexture_v6e46"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(128, 32, 32, 32) region = Rect2(0, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ly4f6"] [sub_resource type="AtlasTexture" id="AtlasTexture_qikhv"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xtgne"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qvokx"]
atlas = ExtResource("2_n6ad3")
region = Rect2(96, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_cc0lq"]
atlas = ExtResource("2_n6ad3")
region = Rect2(128, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_dw7uy"]
atlas = ExtResource("2_n6ad3")
region = Rect2(160, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ecm54"]
atlas = ExtResource("2_n6ad3")
region = Rect2(192, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0l1kh"]
atlas = ExtResource("2_n6ad3")
region = Rect2(224, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_c3gpp"]
atlas = ExtResource("2_n6ad3")
region = Rect2(0, 160, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_myk4l"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 160, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_kwrpx"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 160, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0n461"]
atlas = ExtResource("2_n6ad3")
region = Rect2(96, 160, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_bgbv2"]
atlas = ExtResource("2_n6ad3")
region = Rect2(128, 160, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_h5vay"]
atlas = ExtResource("2_n6ad3")
region = Rect2(160, 160, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_4u621"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(128, 96, 32, 32) region = Rect2(128, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_tqwgk"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ly4f6"]
atlas = ExtResource("2_n6ad3")
region = Rect2(0, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_htqrf"] [sub_resource type="AtlasTexture" id="AtlasTexture_htqrf"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(128, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_vkuli"]
atlas = ExtResource("2_n6ad3")
region = Rect2(160, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hrxdh"]
atlas = ExtResource("2_n6ad3")
region = Rect2(160, 96, 32, 32) region = Rect2(160, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_gjv0h"] [sub_resource type="AtlasTexture" id="AtlasTexture_vkuli"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(160, 64, 32, 32) region = Rect2(96, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_457no"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_n6ad3"] [sub_resource type="AtlasTexture" id="AtlasTexture_n6ad3"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
@@ -75,75 +131,122 @@ region = Rect2(96, 0, 32, 32)
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(96, 0, 32, 32) region = Rect2(96, 0, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_v6e46"] [sub_resource type="AtlasTexture" id="AtlasTexture_gjv0h"]
atlas = ExtResource("2_n6ad3")
region = Rect2(0, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qikhv"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xtgne"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_qvokx"]
atlas = ExtResource("2_n6ad3")
region = Rect2(96, 96, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_cc0lq"]
atlas = ExtResource("2_n6ad3")
region = Rect2(0, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_dw7uy"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ecm54"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0l1kh"]
atlas = ExtResource("2_n6ad3")
region = Rect2(96, 128, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_c3gpp"]
atlas = ExtResource("2_n6ad3")
region = Rect2(0, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_myk4l"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_kwrpx"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_0n461"]
atlas = ExtResource("2_n6ad3")
region = Rect2(96, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_bgbv2"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(0, 64, 32, 32) region = Rect2(0, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_h5vay"] [sub_resource type="AtlasTexture" id="AtlasTexture_1qt2f"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(32, 64, 32, 32) region = Rect2(32, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_4u621"] [sub_resource type="AtlasTexture" id="AtlasTexture_gdvfa"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(64, 64, 32, 32) region = Rect2(64, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_tqwgk"] [sub_resource type="AtlasTexture" id="AtlasTexture_mg2nh"]
atlas = ExtResource("2_n6ad3") atlas = ExtResource("2_n6ad3")
region = Rect2(96, 64, 32, 32) region = Rect2(96, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_gcjjm"]
atlas = ExtResource("2_n6ad3")
region = Rect2(128, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_e3g8f"]
atlas = ExtResource("2_n6ad3")
region = Rect2(160, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_6pjby"]
atlas = ExtResource("2_n6ad3")
region = Rect2(192, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_b0cbm"]
atlas = ExtResource("2_n6ad3")
region = Rect2(224, 64, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_dd46j"]
atlas = ExtResource("2_n6ad3")
region = Rect2(0, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_wvo82"]
atlas = ExtResource("2_n6ad3")
region = Rect2(32, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_kdo6l"]
atlas = ExtResource("2_n6ad3")
region = Rect2(64, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hapb4"]
atlas = ExtResource("2_n6ad3")
region = Rect2(96, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_lof82"]
atlas = ExtResource("2_n6ad3")
region = Rect2(128, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_6toyj"]
atlas = ExtResource("2_n6ad3")
region = Rect2(160, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_2eclv"]
atlas = ExtResource("2_n6ad3")
region = Rect2(192, 32, 32, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ojxu4"]
atlas = ExtResource("2_n6ad3")
region = Rect2(224, 32, 32, 32)
[sub_resource type="SpriteFrames" id="SpriteFrames_v8w1g"] [sub_resource type="SpriteFrames" id="SpriteFrames_v8w1g"]
animations = [{ animations = [{
"frames": [{ "frames": [{
"duration": 2.0,
"texture": SubResource("AtlasTexture_v6e46")
}, {
"duration": 2.0,
"texture": SubResource("AtlasTexture_qikhv")
}, {
"duration": 2.0,
"texture": SubResource("AtlasTexture_xtgne")
}, {
"duration": 2.0,
"texture": SubResource("AtlasTexture_qvokx")
}, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_457no") "texture": SubResource("AtlasTexture_cc0lq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dw7uy")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ecm54")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0l1kh")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_c3gpp")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_myk4l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kwrpx")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0n461")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bgbv2")
}, {
"duration": 5.0,
"texture": SubResource("AtlasTexture_h5vay")
}],
"loop": false,
"name": &"death",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_4u621")
}], }],
"loop": true, "loop": true,
"name": &"fall_down", "name": &"fall_down",
@@ -151,7 +254,7 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_ly4f6") "texture": SubResource("AtlasTexture_tqwgk")
}], }],
"loop": true, "loop": true,
"name": &"fall_down_left", "name": &"fall_down_left",
@@ -159,7 +262,7 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_htqrf") "texture": SubResource("AtlasTexture_ly4f6")
}], }],
"loop": true, "loop": true,
"name": &"fall_down_right", "name": &"fall_down_right",
@@ -167,7 +270,7 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_vkuli") "texture": SubResource("AtlasTexture_htqrf")
}], }],
"loop": true, "loop": true,
"name": &"fall_up", "name": &"fall_up",
@@ -175,7 +278,7 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_hrxdh") "texture": SubResource("AtlasTexture_vkuli")
}], }],
"loop": true, "loop": true,
"name": &"fall_up_left", "name": &"fall_up_left",
@@ -183,7 +286,7 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_gjv0h") "texture": SubResource("AtlasTexture_457no")
}], }],
"loop": true, "loop": true,
"name": &"fall_up_right", "name": &"fall_up_right",
@@ -239,28 +342,28 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_v6e46") "texture": SubResource("AtlasTexture_gjv0h")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_qikhv") "texture": SubResource("AtlasTexture_1qt2f")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_xtgne") "texture": SubResource("AtlasTexture_gdvfa")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_qvokx") "texture": SubResource("AtlasTexture_mg2nh")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_cc0lq") "texture": SubResource("AtlasTexture_gcjjm")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_dw7uy") "texture": SubResource("AtlasTexture_e3g8f")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_ecm54") "texture": SubResource("AtlasTexture_6pjby")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_0l1kh") "texture": SubResource("AtlasTexture_b0cbm")
}], }],
"loop": true, "loop": true,
"name": &"walk_left", "name": &"walk_left",
@@ -268,28 +371,28 @@ animations = [{
}, { }, {
"frames": [{ "frames": [{
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_c3gpp") "texture": SubResource("AtlasTexture_dd46j")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_myk4l") "texture": SubResource("AtlasTexture_wvo82")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_kwrpx") "texture": SubResource("AtlasTexture_kdo6l")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_0n461") "texture": SubResource("AtlasTexture_hapb4")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_bgbv2") "texture": SubResource("AtlasTexture_lof82")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_h5vay") "texture": SubResource("AtlasTexture_6toyj")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_4u621") "texture": SubResource("AtlasTexture_2eclv")
}, { }, {
"duration": 1.0, "duration": 1.0,
"texture": SubResource("AtlasTexture_tqwgk") "texture": SubResource("AtlasTexture_ojxu4")
}], }],
"loop": true, "loop": true,
"name": &"walk_right", "name": &"walk_right",
@@ -307,7 +410,7 @@ script = ExtResource("1_xln5q")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
material = SubResource("ShaderMaterial_i05k5") material = SubResource("ShaderMaterial_i05k5")
sprite_frames = SubResource("SpriteFrames_v8w1g") sprite_frames = SubResource("SpriteFrames_v8w1g")
animation = &"look_around_1" animation = &"walk_right"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 1) position = Vector2(0, 1)
Binary file not shown.