From fa8861d6a1d3946a6c4ff3b24cf8765ec4059afb Mon Sep 17 00:00:00 2001 From: mtrx Date: Sun, 1 Oct 2023 21:07:09 +0200 Subject: [PATCH] implemented death sounds --- assets/sounds/sfx/damage.wav | 3 +++ assets/sounds/sfx/damage.wav.import | 24 ++++++++++++++++++++++++ assets/sounds/sfx/death_sound.wav | 3 +++ assets/sounds/sfx/death_sound.wav.import | 24 ++++++++++++++++++++++++ src/game/level.gd | 4 ++++ src/game/player.tscn | 12 +++++++++++- 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 assets/sounds/sfx/damage.wav create mode 100644 assets/sounds/sfx/damage.wav.import create mode 100644 assets/sounds/sfx/death_sound.wav create mode 100644 assets/sounds/sfx/death_sound.wav.import diff --git a/assets/sounds/sfx/damage.wav b/assets/sounds/sfx/damage.wav new file mode 100644 index 0000000..632a773 --- /dev/null +++ b/assets/sounds/sfx/damage.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ff3a8d723fbfb1f55647f11699550b2e231a5d0d019363af080ef7d4761c60c +size 6531664 diff --git a/assets/sounds/sfx/damage.wav.import b/assets/sounds/sfx/damage.wav.import new file mode 100644 index 0000000..7174bf2 --- /dev/null +++ b/assets/sounds/sfx/damage.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c7laud048l1is" +path="res://.godot/imported/damage.wav-8c4919c614aee00fc00121daa2bc247e.sample" + +[deps] + +source_file="res://assets/sounds/sfx/damage.wav" +dest_files=["res://.godot/imported/damage.wav-8c4919c614aee00fc00121daa2bc247e.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/assets/sounds/sfx/death_sound.wav b/assets/sounds/sfx/death_sound.wav new file mode 100644 index 0000000..35b7fb3 --- /dev/null +++ b/assets/sounds/sfx/death_sound.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b917e1df02f73c7e23e4e062cfec4182ada3ad1c82dfaf69f4ac8ccf458d956 +size 9315610 diff --git a/assets/sounds/sfx/death_sound.wav.import b/assets/sounds/sfx/death_sound.wav.import new file mode 100644 index 0000000..1a483c3 --- /dev/null +++ b/assets/sounds/sfx/death_sound.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c6dy6nea6vaa4" +path="res://.godot/imported/death_sound.wav-74c3ac4e551e080446bef315f79faff8.sample" + +[deps] + +source_file="res://assets/sounds/sfx/death_sound.wav" +dest_files=["res://.godot/imported/death_sound.wav-74c3ac4e551e080446bef315f79faff8.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=1 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/src/game/level.gd b/src/game/level.gd index 420caeb..3e81c09 100644 --- a/src/game/level.gd +++ b/src/game/level.gd @@ -96,5 +96,9 @@ func get_total_distance(): return lap_distance + last_offset func game_over(): + running = false + $player/death_sound.play() print_debug("final score: ", get_total_distance()) + await get_tree().create_timer(3).timeout + get_tree().reload_current_scene() #temp diff --git a/src/game/player.tscn b/src/game/player.tscn index 6e79158..4db5106 100644 --- a/src/game/player.tscn +++ b/src/game/player.tscn @@ -1,9 +1,11 @@ -[gd_scene load_steps=6 format=3 uid="uid://ckau5s2tsb3oc"] +[gd_scene load_steps=8 format=3 uid="uid://ckau5s2tsb3oc"] [ext_resource type="Script" path="res://src/game/player_controller.gd" id="1_g4ij8"] [ext_resource type="Texture2D" uid="uid://d1t1g7hyil82v" path="res://assets/spracer.png" id="2_xal47"] [ext_resource type="Texture2D" uid="uid://ceqcsof04vhqs" path="res://assets/light.png" id="3_qosw5"] [ext_resource type="AudioStream" uid="uid://cc4ffx6b0xjvk" path="res://assets/sounds/sfx/engine_loop.wav" id="4_4ajo8"] +[ext_resource type="AudioStream" uid="uid://c7laud048l1is" path="res://assets/sounds/sfx/damage.wav" id="5_rvolc"] +[ext_resource type="AudioStream" uid="uid://c6dy6nea6vaa4" path="res://assets/sounds/sfx/death_sound.wav" id="6_i0vg5"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_w2nj7"] size = Vector2(36, 20) @@ -44,3 +46,11 @@ rotation_smoothing_speed = 10.0 stream = ExtResource("4_4ajo8") volume_db = -40.467 autoplay = true + +[node name="damage_sounds" type="AudioStreamPlayer" parent="."] +stream = ExtResource("5_rvolc") +volume_db = -25.297 + +[node name="death_sound" type="AudioStreamPlayer" parent="."] +stream = ExtResource("6_i0vg5") +volume_db = -25.297