aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game/audio/sfx/click.oggbin0 -> 7665 bytes
-rw-r--r--game/audio/sfx/click.ogg.import19
-rw-r--r--game/project.godot1
-rw-r--r--game/src/Autoload/SFX.gd20
-rw-r--r--game/src/MainMenu/MainMenu.gd5
5 files changed, 45 insertions, 0 deletions
diff --git a/game/audio/sfx/click.ogg b/game/audio/sfx/click.ogg
new file mode 100644
index 0000000..db6685c
--- /dev/null
+++ b/game/audio/sfx/click.ogg
Binary files differ
diff --git a/game/audio/sfx/click.ogg.import b/game/audio/sfx/click.ogg.import
new file mode 100644
index 0000000..bd62a60
--- /dev/null
+++ b/game/audio/sfx/click.ogg.import
@@ -0,0 +1,19 @@
+[remap]
+
+importer="oggvorbisstr"
+type="AudioStreamOggVorbis"
+uid="uid://ba28aehsahrqp"
+path="res://.godot/imported/click.ogg-384bcd712738d3bf739a83a5627efe9f.oggvorbisstr"
+
+[deps]
+
+source_file="res://audio/sfx/click.ogg"
+dest_files=["res://.godot/imported/click.ogg-384bcd712738d3bf739a83a5627efe9f.oggvorbisstr"]
+
+[params]
+
+loop=false
+loop_offset=0
+bpm=0
+beat_count=0
+bar_beats=4
diff --git a/game/project.godot b/game/project.godot
index 35b92f6..5031276 100644
--- a/game/project.godot
+++ b/game/project.godot
@@ -20,6 +20,7 @@ config/project_settings_override.template="user://settings.cfg"
Events="*res://src/Autoload/Events.gd"
Resolution="*res://src/Autoload/Resolution.gd"
+SFX="*res://src/Autoload/SFX.gd"
Keychain="*res://addons/keychain/Keychain.gd"
[display]
diff --git a/game/src/Autoload/SFX.gd b/game/src/Autoload/SFX.gd
new file mode 100644
index 0000000..5299848
--- /dev/null
+++ b/game/src/Autoload/SFX.gd
@@ -0,0 +1,20 @@
+extends Node
+
+var _loaded_sfx = {}
+
+func _ready():
+ var dir = DirAccess.open("res://audio/sfx/")
+ for fname in dir.get_files():
+ if fname.get_extension() == "ogg":
+ _loaded_sfx[fname.get_basename()] = load("res://audio/sfx/" + fname) # SND-10
+
+# SND-7
+func play(sound):
+ var player = AudioStreamPlayer.new()
+ player.bus = "SFX"
+ player.stream = _loaded_sfx[sound]
+ add_child(player)
+ player.play()
+ await player.finished
+ remove_child(player)
+
diff --git a/game/src/MainMenu/MainMenu.gd b/game/src/MainMenu/MainMenu.gd
index 000dc69..cd333a3 100644
--- a/game/src/MainMenu/MainMenu.gd
+++ b/game/src/MainMenu/MainMenu.gd
@@ -12,23 +12,28 @@ func _ready():
func _on_new_game_button_pressed():
+ SFX.play("click")
print("Start a new game!")
get_tree().change_scene_to_file("res://src/SampleGame.tscn")
func _on_continue_button_pressed():
+ SFX.play("click")
print("Continue last game!")
func _on_multi_player_button_pressed():
+ SFX.play("click")
print("Have fun with friends!")
func _on_options_button_pressed():
+ SFX.play("click")
print("Check out some options!")
options_button_pressed.emit()
func _on_exit_button_pressed():
+ await SFX.play("click")
print("See you later!")
get_tree().quit()