diff --git a/PlayerCharacterBody2D.gd b/PlayerCharacterBody2D.gd index f99d0be..559b436 100644 --- a/PlayerCharacterBody2D.gd +++ b/PlayerCharacterBody2D.gd @@ -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 diff --git a/boxedSpace.gd b/boxedSpace.gd index f743529..ad0bc31 100644 --- a/boxedSpace.gd +++ b/boxedSpace.gd @@ -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() diff --git a/boxedSpace.tscn b/boxedSpace.tscn index 16cee41..8850fc2 100644 --- a/boxedSpace.tscn +++ b/boxedSpace.tscn @@ -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 diff --git a/player.tscn b/player.tscn index f9292ef..4b8d430 100644 --- a/player.tscn +++ b/player.tscn @@ -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 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 index 0000000..5e89698 --- /dev/null +++ b/res/LD54_0.ogg.import @@ -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 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 index 0000000..bfef595 --- /dev/null +++ b/res/hit.ogg.import @@ -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 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 index 0000000..e6c4700 --- /dev/null +++ b/res/jump.ogg.import @@ -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