Merge pull request #35 from MarkGamed7794/origin/sound-effect-rework
Add some new behavior to sound effectspull/43/head
commit
75ee07a04d
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
125
load/sounds.lua
125
load/sounds.lua
|
@ -1,63 +1,98 @@
|
|||
sounds = {
|
||||
sound_paths = {
|
||||
blocks = {
|
||||
I = love.audio.newSource("res/se/piece_i.wav", "static"),
|
||||
J = love.audio.newSource("res/se/piece_j.wav", "static"),
|
||||
L = love.audio.newSource("res/se/piece_l.wav", "static"),
|
||||
O = love.audio.newSource("res/se/piece_o.wav", "static"),
|
||||
S = love.audio.newSource("res/se/piece_s.wav", "static"),
|
||||
T = love.audio.newSource("res/se/piece_t.wav", "static"),
|
||||
Z = love.audio.newSource("res/se/piece_z.wav", "static")
|
||||
I = "res/se/piece_i.wav",
|
||||
J = "res/se/piece_j.wav",
|
||||
L = "res/se/piece_l.wav",
|
||||
O = "res/se/piece_o.wav",
|
||||
S = "res/se/piece_s.wav",
|
||||
T = "res/se/piece_t.wav",
|
||||
Z = "res/se/piece_z.wav"
|
||||
},
|
||||
move = love.audio.newSource("res/se/move.wav", "static"),
|
||||
bottom = love.audio.newSource("res/se/bottom.wav", "static"),
|
||||
cursor = love.audio.newSource("res/se/cursor.wav", "static"),
|
||||
cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"),
|
||||
main_decide = love.audio.newSource("res/se/main_decide.wav", "static"),
|
||||
mode_decide = love.audio.newSource("res/se/mode_decide.wav", "static"),
|
||||
lock = love.audio.newSource("res/se/lock.wav", "static"),
|
||||
hold = love.audio.newSource("res/se/hold.wav", "static"),
|
||||
erase = love.audio.newSource("res/se/erase.wav", "static"),
|
||||
fall = love.audio.newSource("res/se/fall.wav", "static"),
|
||||
ready = love.audio.newSource("res/se/ready.wav", "static"),
|
||||
go = love.audio.newSource("res/se/go.wav", "static"),
|
||||
irs = love.audio.newSource("res/se/irs.wav", "static"),
|
||||
ihs = love.audio.newSource("res/se/ihs.wav", "static"),
|
||||
move = "res/se/move.wav",
|
||||
rotate = "res/se/rotate.wav",
|
||||
kick = "res/se/kick.wav",
|
||||
bottom = "res/se/bottom.wav",
|
||||
cursor = "res/se/cursor.wav",
|
||||
cursor_lr = "res/se/cursor_lr.wav",
|
||||
main_decide = "res/se/main_decide.wav",
|
||||
mode_decide = "res/se/mode_decide.wav",
|
||||
lock = "res/se/lock.wav",
|
||||
hold = "res/se/hold.wav",
|
||||
erase = {
|
||||
single = "res/se/single.wav",
|
||||
double = "res/se/double.wav",
|
||||
triple = "res/se/triple.wav",
|
||||
quad = "res/se/quad.wav"
|
||||
},
|
||||
fall = "res/se/fall.wav",
|
||||
ready = "res/se/ready.wav",
|
||||
go = "res/se/go.wav",
|
||||
irs = "res/se/irs.wav",
|
||||
ihs = "res/se/ihs.wav",
|
||||
-- a secret sound!
|
||||
welcome = love.audio.newSource("res/se/welcomeToCambridge.wav", "static"),
|
||||
welcome = "res/se/welcomeToCambridge.wav",
|
||||
}
|
||||
|
||||
sounds = {}
|
||||
-- Replace each sound effect string with its love audiosource counterpart, but only if it exists. This lets the game handle missing SFX.
|
||||
for k,v in pairs(sound_paths) do
|
||||
if(type(v) == "table") then
|
||||
-- list of subsounds
|
||||
for k2,v2 in pairs(v) do
|
||||
if(love.filesystem.getInfo(sound_paths[k][k2])) then
|
||||
-- this file exists
|
||||
sounds[k] = sounds[k] or {}
|
||||
sounds[k][k2] = love.audio.newSource(sound_paths[k][k2], "static")
|
||||
end
|
||||
end
|
||||
else
|
||||
if(love.filesystem.getInfo(sound_paths[k])) then
|
||||
-- this file exists
|
||||
sounds[k] = love.audio.newSource(sound_paths[k], "static")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function playSE(sound, subsound)
|
||||
if sound ~= nil then
|
||||
if subsound ~= nil then
|
||||
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound][subsound]:isPlaying() then
|
||||
sounds[sound][subsound]:stop()
|
||||
if sounds[sound] then
|
||||
if subsound ~= nil then
|
||||
if sounds[sound][subsound] then
|
||||
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound][subsound]:isPlaying() then
|
||||
sounds[sound][subsound]:stop()
|
||||
end
|
||||
sounds[sound][subsound]:play()
|
||||
end
|
||||
else
|
||||
sounds[sound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound]:isPlaying() then
|
||||
sounds[sound]:stop()
|
||||
end
|
||||
sounds[sound]:play()
|
||||
end
|
||||
sounds[sound][subsound]:play()
|
||||
else
|
||||
sounds[sound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound]:isPlaying() then
|
||||
sounds[sound]:stop()
|
||||
end
|
||||
sounds[sound]:play()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function playSEOnce(sound, subsound)
|
||||
if sound ~= nil then
|
||||
if subsound ~= nil then
|
||||
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound][subsound]:isPlaying() then
|
||||
return
|
||||
if sounds[sound] then
|
||||
if subsound ~= nil then
|
||||
if sounds[sound][subsound] then
|
||||
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound][subsound]:isPlaying() then
|
||||
return
|
||||
end
|
||||
sounds[sound][subsound]:play()
|
||||
end
|
||||
else
|
||||
sounds[sound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound]:isPlaying() then
|
||||
return
|
||||
end
|
||||
sounds[sound]:play()
|
||||
end
|
||||
sounds[sound][subsound]:play()
|
||||
else
|
||||
sounds[sound]:setVolume(config.sfx_volume)
|
||||
if sounds[sound]:isPlaying() then
|
||||
return
|
||||
end
|
||||
sounds[sound]:play()
|
||||
end
|
||||
end
|
||||
end
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -268,7 +268,8 @@ function GameMode:update(inputs, ruleset)
|
|||
end
|
||||
|
||||
if cleared_row_count > 0 then
|
||||
playSE("erase")
|
||||
local row_count_names = {"single","double","triple","quad"}
|
||||
playSE("erase",row_count_names[cleared_row_count] or "quad")
|
||||
self.lcd = self:getLineClearDelay()
|
||||
self.last_lcd = self.lcd
|
||||
self.are = (
|
||||
|
|
|
@ -98,10 +98,12 @@ function Ruleset:attemptRotate(new_inputs, piece, grid, initial)
|
|||
if (grid:canPlacePiece(new_piece)) then
|
||||
piece:setRelativeRotation(rot_dir)
|
||||
self:onPieceRotate(piece, grid)
|
||||
playSE("rotate")
|
||||
else
|
||||
if not(initial and self.enable_IRS_wallkicks == false) then
|
||||
self:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||
end
|
||||
playSE("kick")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue