forked from sharpobject/sgre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sounds.lua
63 lines (55 loc) · 2.06 KB
/
sounds.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
54
55
56
57
58
59
60
61
62
63
bgm = nil
local bgm_table = {}
bgm_table["lobby"] = love.audio.newSource("sg_bgm/SwordGirls_Waiting_Room.mp3")
bgm_table["dungeon"] = love.audio.newSource("sg_bgm/4_sg_bgm_dugeon.mp3")
bgm_table["rewards"] = love.audio.newSource("sg_bgm/3_sg_bgm_result.mp3")
bgm_table["fight"] = love.audio.newSource("sg_bgm/2_sg_bgm_vs_02.mp3")
bgm_table["other_main"] = love.audio.newSource("sg_bgm/5_sg_bgm_main_2.mp3")
local sounds_table = {}
sounds_table["attack"] = "sg_sounds/attack.wav"
sounds_table["buff"] = "sg_sounds/buff.wav"
sounds_table["death"] = "sg_sounds/death.wav"
sounds_table["defend"] = "sg_sounds/defend.wav"
sounds_table["life_buff"] = "sg_sounds/life_buff.wav"
sounds_table["trigger_attack"] = "sg_sounds/trigger_attack.wav"
sounds_table["trigger_defend"] = "sg_sounds/trigger_defend.wav"
sounds_table["trigger_start"] = "sg_sounds/trigger_start.wav"
sounds_table["trigger_spell"] = "sg_sounds/trigger_spell.wav"
sounds_table["trigger_vanish"] = "sg_sounds/trigger_vanish.wav"
sounds_table["coin_start"] = "sg_sounds/coin_start.wav"
sounds_table["coin_end"] = "sg_sounds/coin_end.wav"
local button_sound = love.audio.newSource("sg_sounds/btn_click01.wav")
local cancel_sound = love.audio.newSource("sg_sounds/btn_click02.wav")
for state, source in pairs(bgm_table) do
source:setLooping(true)
end
function play_bgm(state)
if bgm and bgm:isPlaying() and bgm_table[state] == bgm then
return --do nothing if we are already playing the right music for the requested state
end
if bgm then
bgm:stop()
end
bgm = bgm_table[state]
bgm:setVolume(options.music_volume)
bgm:play()
end
function play_button_sound()
button_sound:stop()
button_sound:setVolume(options.sfx_volume)
button_sound:play()
end
function play_cancel_sound()
cancel_sound:stop()
cancel_sound:setVolume(options.sfx_volume)
cancel_sound:play()
end
function play_sound(kind)
sound = sounds_table[kind]
if (sound == nil) then
else
source = love.audio.newSource(sound)
source:setVolume(options.sfx_volume)
source:play()
end
end