]> git.seodisparate.com - LD54/commitdiff
Add music and sfx
authorStephen Seo <seo.disparate@gmail.com>
Sat, 30 Sep 2023 08:07:57 +0000 (17:07 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 30 Sep 2023 08:07:57 +0000 (17:07 +0900)
PlayerCharacterBody2D.gd
boxedSpace.gd
boxedSpace.tscn
player.tscn
res/LD54_0.ogg [new file with mode: 0644]
res/LD54_0.ogg.import [new file with mode: 0644]
res/hit.ogg [new file with mode: 0644]
res/hit.ogg.import [new file with mode: 0644]
res/jump.ogg [new file with mode: 0644]
res/jump.ogg.import [new file with mode: 0644]

index f99d0bee13916398c3190a33a123de040dd2a893..559b436afa253f6820b534abdd4ee74deec26759 100644 (file)
@@ -29,6 +29,9 @@ var health_text_format = "%d"
 
 var particle = preload("res://circleParticle.tscn")
 
+@onready var hit_sfx = $HitSFX
+@onready var jump_sfx = $JumpSFX
+
 func _ready():
        self_sprite.self_modulate = DEFAULT_COLOR
        health_label.add_text(health_text_format % health)
@@ -48,6 +51,7 @@ func _physics_process(delta):
        # Handle Jump.
        if Input.is_action_just_pressed("jump") and is_on_floor():
                velocity.y = JUMP_VELOCITY
+               jump_sfx.play()
 
        # Get the input direction and handle the movement/deceleration.
        # As good practice, you should replace UI actions with custom gameplay actions.
@@ -83,6 +87,7 @@ func damaged(projectile):
                health_label.add_text(health_text_format % health)
                self_sprite.self_modulate = HURT_COLOR
                hurt_timer = HURT_TIME
+               hit_sfx.play()
                if health <= 0:
                        velocity = Vector2(0, 0)
                        collision_layer = 0
index f74352988b95507be0f75f0355150136ebdb349d..ad0bc3110687d18898df14361be0edd4f9fe46d9 100644 (file)
@@ -2,6 +2,7 @@ extends Node2D
 
 @onready var arenaBody = $StaticBody2D
 @onready var player = $CharacterBody2D
+@onready var music = $AudioStreamPlayer
 var projectile = preload("res://circleProjectiles.tscn")
 
 const WAVE_TIME = 5.0
@@ -43,3 +44,4 @@ func on_player_death():
        button.text = "Restart?"
        button.pressed.connect(do_restart)
        player.add_child(button)
+       music.stop()
index 16cee41ed4a89a11c8a9914fc0c88d62c827d1ec..8850fc2360f28d289e35ae36f7f6bd3488c63020 100644 (file)
@@ -1,8 +1,9 @@
-[gd_scene load_steps=8 format=3 uid="uid://dsb4cupghg5of"]
+[gd_scene load_steps=9 format=3 uid="uid://dsb4cupghg5of"]
 
 [ext_resource type="Script" path="res://boxedSpace.gd" id="1_kaapg"]
 [ext_resource type="Script" path="res://boundary.gd" id="2_ifihl"]
 [ext_resource type="PackedScene" uid="uid://dv8hwks0xe3c0" path="res://player.tscn" id="3_b55g5"]
+[ext_resource type="AudioStream" uid="uid://hyd668oirqhx" path="res://res/LD54_0.ogg" id="4_yuav8"]
 
 [sub_resource type="RectangleShape2D" id="RectangleShape2D_usx0l"]
 size = Vector2(1353, 99)
@@ -44,3 +45,7 @@ position = Vector2(1203.5, 322)
 shape = SubResource("RectangleShape2D_oer7k")
 
 [node name="CharacterBody2D" parent="." instance=ExtResource("3_b55g5")]
+
+[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
+stream = ExtResource("4_yuav8")
+autoplay = true
index f9292efbfeb49ee3fdc016714f2936c8df69f354..4b8d4309b992ad82eb6e93d8eef2dc9cb7e52ba6 100644 (file)
@@ -1,6 +1,8 @@
-[gd_scene load_steps=4 format=3 uid="uid://dv8hwks0xe3c0"]
+[gd_scene load_steps=6 format=3 uid="uid://dv8hwks0xe3c0"]
 
 [ext_resource type="Script" path="res://PlayerCharacterBody2D.gd" id="1_8l13s"]
+[ext_resource type="AudioStream" uid="uid://b88dh38cr8v6o" path="res://res/jump.ogg" id="2_ix2ut"]
+[ext_resource type="AudioStream" uid="uid://jfrsvixicrf" path="res://res/hit.ogg" id="3_gq63f"]
 
 [sub_resource type="RectangleShape2D" id="RectangleShape2D_yripi"]
 size = Vector2(40, 40)
@@ -33,3 +35,9 @@ offset_left = -61.0
 offset_top = -62.0
 offset_right = -21.0
 offset_bottom = -22.0
+
+[node name="JumpSFX" type="AudioStreamPlayer" parent="."]
+stream = ExtResource("2_ix2ut")
+
+[node name="HitSFX" type="AudioStreamPlayer" parent="."]
+stream = ExtResource("3_gq63f")
diff --git a/res/LD54_0.ogg b/res/LD54_0.ogg
new file mode 100644 (file)
index 0000000..2d2c61c
Binary files /dev/null and b/res/LD54_0.ogg differ
diff --git a/res/LD54_0.ogg.import b/res/LD54_0.ogg.import
new file mode 100644 (file)
index 0000000..5e89698
--- /dev/null
@@ -0,0 +1,19 @@
+[remap]
+
+importer="oggvorbisstr"
+type="AudioStreamOggVorbis"
+uid="uid://hyd668oirqhx"
+path="res://.godot/imported/LD54_0.ogg-914c66e1067f22212958382587f3d12a.oggvorbisstr"
+
+[deps]
+
+source_file="res://res/LD54_0.ogg"
+dest_files=["res://.godot/imported/LD54_0.ogg-914c66e1067f22212958382587f3d12a.oggvorbisstr"]
+
+[params]
+
+loop=true
+loop_offset=0.0
+bpm=0.0
+beat_count=0
+bar_beats=4
diff --git a/res/hit.ogg b/res/hit.ogg
new file mode 100644 (file)
index 0000000..5b78cfc
Binary files /dev/null and b/res/hit.ogg differ
diff --git a/res/hit.ogg.import b/res/hit.ogg.import
new file mode 100644 (file)
index 0000000..bfef595
--- /dev/null
@@ -0,0 +1,19 @@
+[remap]
+
+importer="oggvorbisstr"
+type="AudioStreamOggVorbis"
+uid="uid://jfrsvixicrf"
+path="res://.godot/imported/hit.ogg-5921110b2893a050cc89cfcb36e76f19.oggvorbisstr"
+
+[deps]
+
+source_file="res://res/hit.ogg"
+dest_files=["res://.godot/imported/hit.ogg-5921110b2893a050cc89cfcb36e76f19.oggvorbisstr"]
+
+[params]
+
+loop=false
+loop_offset=0
+bpm=0
+beat_count=0
+bar_beats=4
diff --git a/res/jump.ogg b/res/jump.ogg
new file mode 100644 (file)
index 0000000..5d8a3fb
Binary files /dev/null and b/res/jump.ogg differ
diff --git a/res/jump.ogg.import b/res/jump.ogg.import
new file mode 100644 (file)
index 0000000..e6c4700
--- /dev/null
@@ -0,0 +1,19 @@
+[remap]
+
+importer="oggvorbisstr"
+type="AudioStreamOggVorbis"
+uid="uid://b88dh38cr8v6o"
+path="res://.godot/imported/jump.ogg-d4ded6631259e8280315e620f2adb600.oggvorbisstr"
+
+[deps]
+
+source_file="res://res/jump.ogg"
+dest_files=["res://.godot/imported/jump.ogg-d4ded6631259e8280315e620f2adb600.oggvorbisstr"]
+
+[params]
+
+loop=false
+loop_offset=0
+bpm=0
+beat_count=0
+bar_beats=4