From 10e5ee3ef6f1fff14ee7733ef3f4da40dc1b28c9 Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Mon, 2 Oct 2023 18:55:26 +0400 Subject: [PATCH] fix hearts & more sounds --- src/models/enemies/bat/Bat.tscn | 11 +++++++++-- src/models/enemies/bat/bat.gd | 1 + src/models/enemies/ghost/Ghost.tscn | 15 ++++++++++++++- src/models/enemies/ghost/ghost.gd | 2 +- src/models/enemies/rat/Rat.tscn | 6 +++++- src/scenes/game/Game.tscn | 19 ++++++++++--------- src/scenes/game/game.gd | 3 +-- src/scripts/enemy_class.gd | 1 + 8 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/models/enemies/bat/Bat.tscn b/src/models/enemies/bat/Bat.tscn index d742495..22968bf 100644 --- a/src/models/enemies/bat/Bat.tscn +++ b/src/models/enemies/bat/Bat.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://src/models/enemies/bat/sprites/bat_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/enemies/bat/bat.gd" type="Script" id=2] [ext_resource path="res://src/models/shadow/shadow.png" type="Texture" id=3] +[ext_resource path="res://res/sounds/bat/damaged.ogg" type="AudioStream" id=4] +[ext_resource path="res://res/sounds/bat/screem.wav" type="AudioStream" id=5] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 4, 3 ) @@ -20,7 +22,6 @@ script = ExtResource( 2 ) use_parent_material = true frames = ExtResource( 1 ) animation = "idle" -frame = 3 playing = true centered = false @@ -38,3 +39,9 @@ shape = SubResource( 2 ) position = Vector2( 11, 21 ) z_index = -1 texture = ExtResource( 3 ) + +[node name="AudioDamage" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 4 ) + +[node name="AudioScreem" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 5 ) diff --git a/src/models/enemies/bat/bat.gd b/src/models/enemies/bat/bat.gd index 50a5387..20097d2 100644 --- a/src/models/enemies/bat/bat.gd +++ b/src/models/enemies/bat/bat.gd @@ -57,3 +57,4 @@ func _shoot(): get_parent().add_child(sonic_wave) sonic_wave.global_position.x = self.global_position.x + 8 sonic_wave.global_position.y = self.global_position.y + 8 + $AudioScreem.play() diff --git a/src/models/enemies/ghost/Ghost.tscn b/src/models/enemies/ghost/Ghost.tscn index a763fe5..3145aff 100644 --- a/src/models/enemies/ghost/Ghost.tscn +++ b/src/models/enemies/ghost/Ghost.tscn @@ -1,8 +1,11 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://src/models/enemies/ghost/sprites/ghost_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/enemies/ghost/ghost.gd" type="Script" id=2] [ext_resource path="res://src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres" type="SpriteFrames" id=3] +[ext_resource path="res://res/sounds/ghost/damaged.wav" type="AudioStream" id=4] +[ext_resource path="res://res/sounds/ghost/dash_charge.wav" type="AudioStream" id=5] +[ext_resource path="res://res/sounds/ghost/dash.wav" type="AudioStream" id=6] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 7, 9 ) @@ -25,6 +28,7 @@ flip_h = true use_parent_material = true frames = ExtResource( 1 ) animation = "idle" +frame = 1 playing = true centered = false @@ -33,3 +37,12 @@ centered = false [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] position = Vector2( 8.5, 13.5 ) shape = SubResource( 1 ) + +[node name="AudioDamage" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 4 ) + +[node name="AudioDashCharge" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 5 ) + +[node name="AudioDash" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 6 ) diff --git a/src/models/enemies/ghost/ghost.gd b/src/models/enemies/ghost/ghost.gd index dcdd6d6..1c9d17d 100644 --- a/src/models/enemies/ghost/ghost.gd +++ b/src/models/enemies/ghost/ghost.gd @@ -34,8 +34,8 @@ func _physics_process(delta): global_position = global_position.move_toward(dash_target, 10) if global_position == dash_target: dashing = false + $AudioDash.play() afterdash = true - if afterdash: afterdash_timer += delta if afterdash_timer >= 1: diff --git a/src/models/enemies/rat/Rat.tscn b/src/models/enemies/rat/Rat.tscn index acae655..a08cff9 100644 --- a/src/models/enemies/rat/Rat.tscn +++ b/src/models/enemies/rat/Rat.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://src/models/enemies/rat/sprites/rat_spriteframes.tres" type="SpriteFrames" id=1] [ext_resource path="res://src/models/enemies/rat/rat.gd" type="Script" id=2] [ext_resource path="res://src/models/shadow/shadow.png" type="Texture" id=3] +[ext_resource path="res://res/sounds/rat/damaged.wav" type="AudioStream" id=4] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 8, 3.5 ) @@ -29,3 +30,6 @@ shape = SubResource( 1 ) position = Vector2( 11, 9 ) z_index = -1 texture = ExtResource( 3 ) + +[node name="AudioDamage" type="AudioStreamPlayer" parent="."] +stream = ExtResource( 4 ) diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index f22fac6..ef0fe04 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -27,14 +27,14 @@ extents = Vector2( 140, 10.125 ) atlas = ExtResource( 6 ) region = Rect2( 155, 0, 31, 11 ) -[sub_resource type="AtlasTexture" id=8] -atlas = ExtResource( 6 ) -region = Rect2( 124, 0, 31, 11 ) - [sub_resource type="AtlasTexture" id=9] atlas = ExtResource( 6 ) region = Rect2( 93, 0, 31, 11 ) +[sub_resource type="AtlasTexture" id=8] +atlas = ExtResource( 6 ) +region = Rect2( 124, 0, 31, 11 ) + [sub_resource type="AtlasTexture" id=10] atlas = ExtResource( 6 ) region = Rect2( 62, 0, 31, 11 ) @@ -49,10 +49,10 @@ region = Rect2( 0, 0, 31, 11 ) [sub_resource type="SpriteFrames" id=4] animations = [ { -"frames": [ SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ) ], -"loop": true, -"name": "default", -"speed": 5.0 +"frames": [ SubResource( 7 ), SubResource( 9 ), SubResource( 8 ), SubResource( 10 ), SubResource( 11 ), SubResource( 12 ) ], +"loop": false, +"name": "idle", +"speed": 0.0 } ] [sub_resource type="Animation" id=5] @@ -209,7 +209,7 @@ margin_bottom = 40.0 [node name="HealthSprite" type="AnimatedSprite" parent="UIWrapper/UI/Left/Health"] position = Vector2( 52, 156 ) frames = SubResource( 4 ) -frame = 5 +animation = "idle" centered = false [node name="PlayerIcon" type="Sprite" parent="UIWrapper/UI/Left"] @@ -252,6 +252,7 @@ margin_right = 40.0 margin_bottom = 40.0 [node name="Cards" type="Control" parent="UIWrapper/UI"] +visible = false margin_right = 320.0 margin_bottom = 120.0 diff --git a/src/scenes/game/game.gd b/src/scenes/game/game.gd index 85a6d01..7f211f4 100644 --- a/src/scenes/game/game.gd +++ b/src/scenes/game/game.gd @@ -13,7 +13,7 @@ var mob_threshold = [5, 7, 10, 7] func _ready(): Global.playing = true - Global.play_time = 55 + Global.play_time = .0 Global.health = 5 Global.add_health(0) @@ -33,7 +33,6 @@ func _physics_process(delta): randomize() card_placeholder.get_node("Card").frame = cards.pop_at(randi()%cards.size()) $UIWrapper/UI/Cards.visible = true - #TODO Pause $UIWrapper/UI/LevelProgressBar/ColorRect.rect_size.x = (Global.play_time - difficulty * 60) / 60.0 * 300 diff --git a/src/scripts/enemy_class.gd b/src/scripts/enemy_class.gd index ef6b37c..9b65828 100644 --- a/src/scripts/enemy_class.gd +++ b/src/scripts/enemy_class.gd @@ -19,6 +19,7 @@ var frozen = false func deal_damage(amount): hp -= amount + $AudioDamage.play() if hp <= 0: death()