From 3e0f1c99d5270fe119d13596cc8c51c72d328b60 Mon Sep 17 00:00:00 2001 From: Minimata Date: Sat, 2 Aug 2025 23:57:02 +0200 Subject: [PATCH] feat: them skeletons man + reload after dancing --- damageable/damageable.gd | 6 + damageable/hitbox.tscn | 1 + ennemy/skeleton.gd | 43 ++++ ennemy/skeleton.gd.uid | 1 + ennemy/skeleton.tscn | 477 +++++++++++++++++++++++++++++++++++++++ main.gd | 2 +- main.tscn | 284 ++++++++++++++++++++++- player/player.gd | 21 +- player/player.tscn | 25 +- 9 files changed, 851 insertions(+), 9 deletions(-) create mode 100644 ennemy/skeleton.gd create mode 100644 ennemy/skeleton.gd.uid create mode 100644 ennemy/skeleton.tscn diff --git a/damageable/damageable.gd b/damageable/damageable.gd index d34148b..c743a10 100644 --- a/damageable/damageable.gd +++ b/damageable/damageable.gd @@ -7,6 +7,7 @@ class_name Damageable var active = true signal got_hit +signal die func set_active(new_active: bool): active = new_active @@ -16,5 +17,10 @@ func damage(value: int = 0, direction: Vector2 = Vector2.UP): return health -= value + if health <= 0: + die.emit() + return + get_parent().velocity = hitback_velocity * direction got_hit.emit() + diff --git a/damageable/hitbox.tscn b/damageable/hitbox.tscn index 6d207d5..c470a08 100644 --- a/damageable/hitbox.tscn +++ b/damageable/hitbox.tscn @@ -5,4 +5,5 @@ [node name="Hitbox" type="Area2D"] script = ExtResource("1_n3l2p") +[connection signal="area_entered" from="." to="." method="_on_body_entered"] [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/ennemy/skeleton.gd b/ennemy/skeleton.gd new file mode 100644 index 0000000..ff1a384 --- /dev/null +++ b/ennemy/skeleton.gd @@ -0,0 +1,43 @@ +extends AnimatedSprite2D + +@onready var hitbox_2: Area2D = $Hitbox2 +@onready var hitbox: Area2D = $Hitbox +@onready var wait_to_die: Timer = $WaitToDie +@onready var hitting: Timer = $Hitting +@onready var wait_to_hit: Timer = $WaitToHit + +var is_dying = false + +func start_dancing(): + play("dance") + +func hit(): + if is_dying: + return + + hitbox.monitorable = true + hitbox.monitoring = true + play("hit") + hitting.start() + +func stop_hitting(): + if is_dying: + return + + hitbox.monitorable = false + hitbox.monitoring = false + + play("idle") + wait_to_hit.start() + +func _on_damageable_die() -> void: + hitbox.set_deferred("monitorable", false) + hitbox.set_deferred("monitoring", false) + hitbox_2.set_deferred("monitorable", false) + hitbox_2.set_deferred("monitoring", false) + is_dying = true + play("die") + wait_to_die.start() + +func _on_wait_to_die_timeout() -> void: + queue_free() diff --git a/ennemy/skeleton.gd.uid b/ennemy/skeleton.gd.uid new file mode 100644 index 0000000..ba0550c --- /dev/null +++ b/ennemy/skeleton.gd.uid @@ -0,0 +1 @@ +uid://b0ewbthpfsy7t diff --git a/ennemy/skeleton.tscn b/ennemy/skeleton.tscn new file mode 100644 index 0000000..1f21d71 --- /dev/null +++ b/ennemy/skeleton.tscn @@ -0,0 +1,477 @@ +[gd_scene load_steps=67 format=3 uid="uid://b2fyaj2fmrug7"] + +[ext_resource type="Texture2D" uid="uid://din26pdtyka1n" path="res://ennemy/Skeleton/Sprite Sheets/Skeleton Hit.png" id="1_yndcr"] +[ext_resource type="Texture2D" uid="uid://bpxn5oa3r3121" path="res://ennemy/Skeleton/Sprite Sheets/Skeleton Dead.png" id="2_sx7nw"] +[ext_resource type="Texture2D" uid="uid://kd8wotp135ud" path="res://ennemy/Skeleton/Sprite Sheets/Skeleton Attack.png" id="3_whaqf"] +[ext_resource type="Texture2D" uid="uid://d4hj35wb0pm2b" path="res://ennemy/Skeleton/Sprite Sheets/Skeleton Idle.png" id="4_g7r65"] +[ext_resource type="Script" uid="uid://bhbn4pngdfk7w" path="res://damageable/damageable.gd" id="5_oqxir"] +[ext_resource type="Script" uid="uid://b0ewbthpfsy7t" path="res://ennemy/skeleton.gd" id="5_sx7nw"] +[ext_resource type="PackedScene" uid="uid://7sqwi3lygb1u" path="res://damageable/hitbox.tscn" id="6_kopbd"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_yvsr8"] +atlas = ExtResource("1_yndcr") +region = Rect2(0, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tko6h"] +atlas = ExtResource("1_yndcr") +region = Rect2(60, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_am8a1"] +atlas = ExtResource("1_yndcr") +region = Rect2(90, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8dc3g"] +atlas = ExtResource("1_yndcr") +region = Rect2(120, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_htgcl"] +atlas = ExtResource("2_sx7nw") +region = Rect2(0, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_smeu8"] +atlas = ExtResource("2_sx7nw") +region = Rect2(33, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_f3y11"] +atlas = ExtResource("2_sx7nw") +region = Rect2(66, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_cpm2s"] +atlas = ExtResource("2_sx7nw") +region = Rect2(99, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_u81y6"] +atlas = ExtResource("2_sx7nw") +region = Rect2(132, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_rt5wr"] +atlas = ExtResource("2_sx7nw") +region = Rect2(165, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_mnw77"] +atlas = ExtResource("2_sx7nw") +region = Rect2(198, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vjgyh"] +atlas = ExtResource("2_sx7nw") +region = Rect2(231, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_d5iia"] +atlas = ExtResource("2_sx7nw") +region = Rect2(264, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_asu84"] +atlas = ExtResource("2_sx7nw") +region = Rect2(297, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qwt6e"] +atlas = ExtResource("2_sx7nw") +region = Rect2(330, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_off2o"] +atlas = ExtResource("2_sx7nw") +region = Rect2(363, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_tttfs"] +atlas = ExtResource("2_sx7nw") +region = Rect2(396, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1iygd"] +atlas = ExtResource("2_sx7nw") +region = Rect2(429, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_g5xqc"] +atlas = ExtResource("2_sx7nw") +region = Rect2(462, 0, 33, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_s4o1y"] +atlas = ExtResource("1_yndcr") +region = Rect2(0, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_7mmqq"] +atlas = ExtResource("1_yndcr") +region = Rect2(30, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3exxq"] +atlas = ExtResource("1_yndcr") +region = Rect2(60, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5aa3q"] +atlas = ExtResource("1_yndcr") +region = Rect2(90, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bmvma"] +atlas = ExtResource("1_yndcr") +region = Rect2(120, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_shlp4"] +atlas = ExtResource("1_yndcr") +region = Rect2(150, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_2n44k"] +atlas = ExtResource("1_yndcr") +region = Rect2(180, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_86lig"] +atlas = ExtResource("1_yndcr") +region = Rect2(210, 0, 30, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ldnlw"] +atlas = ExtResource("3_whaqf") +region = Rect2(0, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_qe8ju"] +atlas = ExtResource("3_whaqf") +region = Rect2(43, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bnk2o"] +atlas = ExtResource("3_whaqf") +region = Rect2(86, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_oosfy"] +atlas = ExtResource("3_whaqf") +region = Rect2(129, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_nf4f2"] +atlas = ExtResource("3_whaqf") +region = Rect2(172, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_xkvoa"] +atlas = ExtResource("3_whaqf") +region = Rect2(215, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_t5kpo"] +atlas = ExtResource("3_whaqf") +region = Rect2(258, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pw0td"] +atlas = ExtResource("3_whaqf") +region = Rect2(301, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_37eu1"] +atlas = ExtResource("3_whaqf") +region = Rect2(344, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0wkqm"] +atlas = ExtResource("3_whaqf") +region = Rect2(387, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ve5sr"] +atlas = ExtResource("3_whaqf") +region = Rect2(430, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5s44m"] +atlas = ExtResource("3_whaqf") +region = Rect2(473, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ibca3"] +atlas = ExtResource("3_whaqf") +region = Rect2(516, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_g3y5b"] +atlas = ExtResource("3_whaqf") +region = Rect2(559, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1slqb"] +atlas = ExtResource("3_whaqf") +region = Rect2(602, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_uo83y"] +atlas = ExtResource("3_whaqf") +region = Rect2(645, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_y0aao"] +atlas = ExtResource("3_whaqf") +region = Rect2(688, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wm5rm"] +atlas = ExtResource("3_whaqf") +region = Rect2(731, 0, 43, 37) + +[sub_resource type="AtlasTexture" id="AtlasTexture_vieuh"] +atlas = ExtResource("4_g7r65") +region = Rect2(0, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yjja3"] +atlas = ExtResource("4_g7r65") +region = Rect2(24, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_l0gw7"] +atlas = ExtResource("4_g7r65") +region = Rect2(48, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_inymm"] +atlas = ExtResource("4_g7r65") +region = Rect2(72, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jcxqu"] +atlas = ExtResource("4_g7r65") +region = Rect2(96, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_0arob"] +atlas = ExtResource("4_g7r65") +region = Rect2(120, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_dij0e"] +atlas = ExtResource("4_g7r65") +region = Rect2(144, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_k1udn"] +atlas = ExtResource("4_g7r65") +region = Rect2(168, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_wat4s"] +atlas = ExtResource("4_g7r65") +region = Rect2(192, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ywjan"] +atlas = ExtResource("4_g7r65") +region = Rect2(216, 0, 24, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_m74q3"] +atlas = ExtResource("4_g7r65") +region = Rect2(240, 0, 24, 32) + +[sub_resource type="SpriteFrames" id="SpriteFrames_getpj"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_yvsr8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tko6h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_am8a1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_8dc3g") +}], +"loop": true, +"name": &"dance", +"speed": 15.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_htgcl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_smeu8") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_f3y11") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_cpm2s") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_u81y6") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_rt5wr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_mnw77") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_vjgyh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_d5iia") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_asu84") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qwt6e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_off2o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_tttfs") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1iygd") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_g5xqc") +}], +"loop": false, +"name": &"die", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_s4o1y") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_7mmqq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_3exxq") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5aa3q") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bmvma") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_shlp4") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_2n44k") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_86lig") +}], +"loop": false, +"name": &"got_hit", +"speed": 10.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_ldnlw") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_qe8ju") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_bnk2o") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_oosfy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_nf4f2") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_xkvoa") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_t5kpo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pw0td") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_37eu1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0wkqm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ve5sr") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5s44m") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ibca3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_g3y5b") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1slqb") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_uo83y") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_y0aao") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wm5rm") +}], +"loop": false, +"name": &"hit", +"speed": 17.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_vieuh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yjja3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_l0gw7") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_inymm") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jcxqu") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_0arob") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_dij0e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_k1udn") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_wat4s") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ywjan") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_m74q3") +}], +"loop": true, +"name": &"idle", +"speed": 10.0 +}] + +[sub_resource type="CircleShape2D" id="CircleShape2D_qsp4k"] +radius = 6.08276 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_kq58d"] +size = Vector2(6, 21) + +[node name="Skeleton" type="AnimatedSprite2D"] +sprite_frames = SubResource("SpriteFrames_getpj") +animation = &"die" +autoplay = "idle" +flip_h = true +script = ExtResource("5_sx7nw") + +[node name="Hitbox" parent="." instance=ExtResource("6_kopbd")] +hitback_direction = Vector2(-1, -1) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] +position = Vector2(-8, 8) +shape = SubResource("CircleShape2D_qsp4k") + +[node name="Hitbox2" parent="." instance=ExtResource("6_kopbd")] +hitback_direction = Vector2(-1, -1) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox2"] +position = Vector2(4, 5.5) +shape = SubResource("RectangleShape2D_kq58d") + +[node name="Damageable" type="Node" parent="Hitbox2"] +script = ExtResource("5_oqxir") +health = 1 +hitback_velocity = 0.0 +metadata/_custom_type_script = "uid://bhbn4pngdfk7w" + +[node name="WaitToDie" type="Timer" parent="."] +wait_time = 3.0 +one_shot = true + +[node name="Hitting" type="Timer" parent="."] +one_shot = true + +[node name="WaitToHit" type="Timer" parent="."] +wait_time = 3.0 + +[connection signal="die" from="Hitbox2/Damageable" to="." method="_on_damageable_die"] +[connection signal="timeout" from="WaitToDie" to="." method="_on_wait_to_die_timeout"] +[connection signal="timeout" from="Hitting" to="." method="stop_hitting"] +[connection signal="timeout" from="WaitToHit" to="." method="hit"] diff --git a/main.gd b/main.gd index 535ada0..79513f4 100644 --- a/main.gd +++ b/main.gd @@ -55,7 +55,7 @@ func _on_start_dancing() -> void: dance_cutscene.play("dance") func restart_at_first_scene(): - pass + get_tree().change_scene_to_file("res://main.tscn") func to_main_menu(): pass diff --git a/main.tscn b/main.tscn index 17f059f..4a98bd7 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=101 format=4 uid="uid://s1cx1gvt4bed"] +[gd_scene load_steps=126 format=4 uid="uid://s1cx1gvt4bed"] [ext_resource type="Script" uid="uid://cvtt52wodbopm" path="res://main.gd" id="1_272bh"] [ext_resource type="PackedScene" uid="uid://yvp44oauis4n" path="res://player/player.tscn" id="1_ig7tw"] @@ -21,6 +21,8 @@ [ext_resource type="Texture2D" uid="uid://d3t1fn35skpip" path="res://player/assets/idle sheet-Sheet.png" id="14_82xsv"] [ext_resource type="Texture2D" uid="uid://oocxl803i4aa" path="res://player/red_hood_profile.tres" id="14_getpj"] [ext_resource type="PackedScene" uid="uid://c5tp7c70qkxe3" path="res://arrow/arrow_spawner.tscn" id="15_vivmo"] +[ext_resource type="Texture2D" uid="uid://dalv1q1xpbp52" path="res://world_assets/Pixel Art Platformer/TX FX Torch Flame.png" id="18_d13ii"] +[ext_resource type="PackedScene" uid="uid://b2fyaj2fmrug7" path="res://ennemy/skeleton.tscn" id="19_d13ii"] [sub_resource type="AtlasTexture" id="AtlasTexture_ycdy4"] atlas = ExtResource("3_dg77c") @@ -498,6 +500,168 @@ animations = [{ atlas = ExtResource("14_82xsv") region = Rect2(663, 28, 14, 13) +[sub_resource type="AtlasTexture" id="AtlasTexture_wy5fy"] +atlas = ExtResource("18_d13ii") +region = Rect2(21, 21, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gx4rg"] +atlas = ExtResource("18_d13ii") +region = Rect2(42, 21, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5dllo"] +atlas = ExtResource("18_d13ii") +region = Rect2(63, 21, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_phcyf"] +atlas = ExtResource("18_d13ii") +region = Rect2(84, 21, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_birbe"] +atlas = ExtResource("18_d13ii") +region = Rect2(105, 21, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_f1p13"] +atlas = ExtResource("18_d13ii") +region = Rect2(0, 42, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4obbf"] +atlas = ExtResource("18_d13ii") +region = Rect2(21, 42, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ovcoh"] +atlas = ExtResource("18_d13ii") +region = Rect2(42, 42, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_ppx11"] +atlas = ExtResource("18_d13ii") +region = Rect2(63, 42, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_1yv1y"] +atlas = ExtResource("18_d13ii") +region = Rect2(84, 42, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5yh34"] +atlas = ExtResource("18_d13ii") +region = Rect2(105, 42, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_pjuso"] +atlas = ExtResource("18_d13ii") +region = Rect2(0, 63, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_23xmf"] +atlas = ExtResource("18_d13ii") +region = Rect2(21, 63, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_swlj1"] +atlas = ExtResource("18_d13ii") +region = Rect2(42, 63, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_yysqy"] +atlas = ExtResource("18_d13ii") +region = Rect2(63, 63, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_n5t1e"] +atlas = ExtResource("18_d13ii") +region = Rect2(84, 63, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_h6isl"] +atlas = ExtResource("18_d13ii") +region = Rect2(105, 63, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_53bls"] +atlas = ExtResource("18_d13ii") +region = Rect2(0, 84, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_lwnsi"] +atlas = ExtResource("18_d13ii") +region = Rect2(21, 84, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_41lik"] +atlas = ExtResource("18_d13ii") +region = Rect2(42, 84, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_jbvwl"] +atlas = ExtResource("18_d13ii") +region = Rect2(63, 84, 21, 21) + +[sub_resource type="AtlasTexture" id="AtlasTexture_sn1fb"] +atlas = ExtResource("18_d13ii") +region = Rect2(84, 84, 21, 21) + +[sub_resource type="SpriteFrames" id="SpriteFrames_yvsr8"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_wy5fy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gx4rg") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5dllo") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_phcyf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_birbe") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_f1p13") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4obbf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ovcoh") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_ppx11") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_1yv1y") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5yh34") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_pjuso") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_23xmf") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_swlj1") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_yysqy") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_n5t1e") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_h6isl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_53bls") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_lwnsi") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_41lik") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_jbvwl") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_sn1fb") +}], +"loop": true, +"name": &"default", +"speed": 22.0 +}] + [sub_resource type="AtlasTexture" id="AtlasTexture_kek77"] atlas = ExtResource("4_ycdy4") region = Rect2(14, 9, 6, 5) @@ -670,7 +834,7 @@ _data = { [sub_resource type="Animation" id="Animation_2cqfq"] resource_name = "dance" -length = 10.0 +length = 8.0 tracks/0/type = "method" tracks/0/imported = false tracks/0/enabled = true @@ -692,7 +856,7 @@ tracks/1/path = NodePath("OpeningFadeToBlack:color") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(5.02, 7.99, 10), +"times": PackedFloat32Array(3, 6, 8), "transitions": PackedFloat32Array(1, 1, 1), "update": 0, "values": [Color(0, 0, 0, 0), Color(0, 0, 0, 1), Color(0, 0, 0, 1)] @@ -711,6 +875,62 @@ tracks/2/keys = { "method": &"play" }] } +tracks/3/type = "method" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Skeleton") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [&"dance", 1.0, false], +"method": &"play" +}] +} +tracks/4/type = "method" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Skeleton2") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [&"dance", 1.0, false], +"method": &"play" +}] +} +tracks/5/type = "method" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Skeleton3") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [&"dance", 1.0, false], +"method": &"play" +}] +} +tracks/6/type = "method" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath(".") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(8), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"restart_at_first_scene" +}] +} [sub_resource type="Animation" id="Animation_yaehf"] length = 0.001 @@ -826,6 +1046,48 @@ tracks/2/keys = { "method": &"queue_free" }] } +tracks/3/type = "method" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Skeleton") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"stop_hitting" +}] +} +tracks/4/type = "method" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Skeleton2") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"stop_hitting" +}] +} +tracks/5/type = "method" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Skeleton3") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"hit" +}] +} [sub_resource type="Animation" id="Animation_82xsv"] length = 0.001 @@ -1049,6 +1311,22 @@ right_picture = SubResource("AtlasTexture_uypp3") position = Vector2(4032, -32) texture = ExtResource("10_2cqfq") +[node name="Firewall" type="AnimatedSprite2D" parent="."] +modulate = Color(0.849078, 0.295655, 0.0322732, 1) +position = Vector2(4465, -11) +sprite_frames = SubResource("SpriteFrames_yvsr8") +autoplay = "default" +frame_progress = 0.0543026 + +[node name="Skeleton" parent="." instance=ExtResource("19_d13ii")] +position = Vector2(3753, -16) + +[node name="Skeleton2" parent="." instance=ExtResource("19_d13ii")] +position = Vector2(3822, -16) + +[node name="Skeleton3" parent="." instance=ExtResource("19_d13ii")] +position = Vector2(3935, -16) + [node name="Player" parent="." instance=ExtResource("1_ig7tw")] [node name="BubblesBack" type="TileMapLayer" parent="."] diff --git a/player/player.gd b/player/player.gd index cd08706..681bc42 100644 --- a/player/player.gd +++ b/player/player.gd @@ -11,6 +11,9 @@ var jump_velocity = 400.0 @export_range(0, 10, 0.1, "or_greater") var gravity_modifier = 1 +@onready var hitting: Timer = $Hitting +@onready var hitbox: Area2D = $Hitbox + @onready var sword: AnimatedSprite2D = $Sword @onready var damageable: Damageable = $Damageable @onready var shield: AnimatedSprite2D = $Shield @@ -20,6 +23,7 @@ var current_sprite: AnimatedSprite2D var is_in_cutscene = false # back to true on build var current_animation = "idle" +var is_hitting = false var has_shield = false var has_sword = false var has_armor = false @@ -62,6 +66,12 @@ func _physics_process(delta: float) -> void: move_and_slide() return + if is_hitting: + current_animation = "hit" + velocity.x = move_toward(velocity.x, 0, speed) + move_and_slide() + return + if not is_on_floor(): velocity += get_gravity() * delta * gravity_modifier @@ -95,8 +105,15 @@ func _physics_process(delta: float) -> void: move_and_slide() func hit(): - print("hit") - current_animation = "hit" + is_hitting = true + hitting.start() + hitbox.monitorable = true + hitbox.monitoring = true + +func _on_hitting_timeout() -> void: + is_hitting = false + hitbox.monitorable = false + hitbox.monitoring = false func _on_dialogue_manager_dialogue_ended() -> void: set_in_play() diff --git a/player/player.tscn b/player/player.tscn index 464a39f..bb13606 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=63 format=3 uid="uid://yvp44oauis4n"] +[gd_scene load_steps=65 format=3 uid="uid://yvp44oauis4n"] [ext_resource type="Script" uid="uid://c1fqj3lba7wik" path="res://player/player.gd" id="1_yw30f"] [ext_resource type="Texture2D" uid="uid://dxsbbcagqkiid" path="res://player/assets/RunArmeEpee.png" id="2_hg6s5"] @@ -10,6 +10,7 @@ [ext_resource type="Texture2D" uid="uid://dsxvqsh3umw01" path="res://player/assets/RunCycle.png" id="5_boad6"] [ext_resource type="PackedScene" uid="uid://djwoetcyvvofc" path="res://damageable/damageable.tscn" id="5_g6k8r"] [ext_resource type="Shape2D" uid="uid://6rhdwj5jxbxn" path="res://player/player_collision.tres" id="5_qjkh3"] +[ext_resource type="PackedScene" uid="uid://7sqwi3lygb1u" path="res://damageable/hitbox.tscn" id="11_2ieo8"] [sub_resource type="AtlasTexture" id="AtlasTexture_tqiix"] atlas = ExtResource("3_hg6s5") @@ -234,7 +235,7 @@ animations = [{ "duration": 1.0, "texture": SubResource("AtlasTexture_a1u5o") }], -"loop": true, +"loop": false, "name": &"hit", "speed": 12.0 }, { @@ -460,6 +461,8 @@ animations = [{ "speed": 14.0 }] +[sub_resource type="CircleShape2D" id="CircleShape2D_ebec5"] + [node name="Player" type="CharacterBody2D"] collision_layer = 3 script = ExtResource("1_yw30f") @@ -475,7 +478,8 @@ position = Vector2(0, -16) sprite_frames = SubResource("SpriteFrames_jfgyi") animation = &"hit" autoplay = "idle" -frame_progress = 0.277569 +frame = 5 +frame_progress = 1.0 [node name="Shield" type="AnimatedSprite2D" parent="."] visible = false @@ -497,3 +501,18 @@ shape = ExtResource("5_qjkh3") [node name="Damageable" parent="." instance=ExtResource("5_g6k8r")] hitback_velocity = 400.0 + +[node name="Hitting" type="Timer" parent="."] +wait_time = 0.5 +one_shot = true + +[node name="Hitbox" parent="." instance=ExtResource("11_2ieo8")] +monitoring = false +monitorable = false +damage = 10 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] +position = Vector2(16, -10) +shape = SubResource("CircleShape2D_ebec5") + +[connection signal="timeout" from="Hitting" to="." method="_on_hitting_timeout"]