forked from loganfechner/ap-performance-task
-
Notifications
You must be signed in to change notification settings - Fork 0
/
soundfx.lua
34 lines (29 loc) · 808 Bytes
/
soundfx.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local SoundFX = { sounds = {} }
local hit = love.audio.newSource("snd/Hit.wav", "static")
local shoot = love.audio.newSource("snd/GunFire.wav", "static")
local killed = love.audio.newSource("snd/Killed.wav", "static")
local powerup = love.audio.newSource("snd/Powerup.wav", "static")
local walk = love.audio.newSource("snd/walk.wav", "static")
walk:setVolume(.3)
function SoundFX:initialize()
self:newFX("hit", hit)
self:newFX("shoot", shoot)
self:newFX("killed", killed)
self:newFX("powerup", powerup)
self:newFX("walk", walk)
end
function SoundFX:newFX(name, source)
self.sounds[#self.sounds+1] = {
name = name,
source = source
}
end
function SoundFX:play(name)
for i = 1, #self.sounds do
local s = self.sounds[i]
if s.name == name then
s.source:play()
end
end
end
return SoundFX