-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaudio.lua
More file actions
50 lines (30 loc) · 1.14 KB
/
Copy pathaudio.lua
File metadata and controls
50 lines (30 loc) · 1.14 KB
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
audio = class('audio')
function audio:initialize()
self.boom = love.audio.newSource('audio/missile_explode.ogg','static')
self.launch = love.audio.newSource('audio/launch_bomb.ogg','static')
self.start = love.audio.newSource('audio/start_level.ogg','static')
self.over = love.audio.newSource('audio/game_over.ogg','static')
self.noammo = love.audio.newSource('audio/no_ammo.ogg','static')
end
function audio:play(sound)
if sound == 'boom' then
self.boom:stop()
self.boom:play()
elseif sound == 'launch' then
if not self.boom:isPlaying() then
self.launch:stop()
self.launch:play()
end
elseif sound == 'start_level' then
self.start:stop()
self.start:play()
elseif sound == 'game_over' then
self.over:stop()
self.over:play()
elseif sound == 'no_ammo' then
if not self.boom:isPlaying() then
self.noammo:stop()
self.noammo:play()
end
end
end