aboutsummaryrefslogtreecommitdiff
path: root/game/src/Autoload
diff options
context:
space:
mode:
Diffstat (limited to 'game/src/Autoload')
-rw-r--r--game/src/Autoload/SFX.gd20
1 files changed, 20 insertions, 0 deletions
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)
+