summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-12 23:26:52 +0800
committerEltrac <hi@guhub.cn>2025-03-12 23:26:52 +0800
commit93be21bd9694287397c96f0cf93c9565d53b6d61 (patch)
tree06840f96ad84101d2a5ab2fec2eaf38423d4a96d /utils
parent33cf1a9f7fe9a87923db11f8d1e2a7cf756a690a (diff)
feat(audio): play projectile sound when player shoots
Diffstat (limited to 'utils')
-rw-r--r--utils/audio.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils/audio.lua b/utils/audio.lua
new file mode 100644
index 0000000..ecf0cc9
--- /dev/null
+++ b/utils/audio.lua
@@ -0,0 +1,21 @@
+local audio = {}
+
+local resources = {
+ projectile = "sound/projectile.wav",
+ intenseFight = "music/intenseFight.wav",
+}
+
+function audio.load()
+ audioData = {}
+ for name, path in pairs(resources) do
+ audioData[name] = love.audio.newSource("resources/" .. path, "stream")
+ end
+end
+
+function audio.play(name)
+ if audioData[name] then
+ love.audio.play(audioData[name])
+ end
+end
+
+return audio