-
Notifications
You must be signed in to change notification settings - Fork 1
/
sound.lua
53 lines (45 loc) · 1.01 KB
/
sound.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local sound = {}
local newSource = love.audio.newSource
local getInfo = love.filesystem.getInfo
local soundlist = {
switch = 'data/switch.ogg',
portal = 'data/Portal.ogg',
shift05 = 'data/Shifting05.ogg',
shift10 = 'data/Shifting10.ogg',
shift15 = 'data/Shifting15.ogg',
shift20 = 'data/Shifting20.ogg',
death = 'data/death.ogg',
selection = 'data/select.ogg',
squareC2 = 'data/squareC2.ogg',
squareC3 = 'data/squareC3.ogg',
squareC4 = 'data/squareC4.ogg',
squareC5 = 'data/squareC5.ogg'
}
for k,v in pairs(soundlist) do
if getInfo(v) then
sound[k] = newSource(v, 'static')
end
end
function sound.tryPlay(snd)
if snd then
snd:play()
end
end
function sound.restart(snd)
if snd then
snd:stop()
snd:play()
end
end
function sound.pickShiftingSound(magnitude)
if magnitude < 5 then
return sound.shift05
elseif magnitude < 10 then
return sound.shift10
elseif magnitude < 15 then
return sound.shift15
else
return sound.shift20
end
end
return sound