Catch up to main, and push changes to sfx

pull/35/head
MarkGamed7794 2021-09-12 02:59:05 -04:00
parent 0e82a8758c
commit 71ecd51cde
8 changed files with 88 additions and 45 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

View File

@ -1,63 +1,101 @@
sounds = { sounds = {
blocks = { blocks = {
I = love.audio.newSource("res/se/piece_i.wav", "static"), I = "res/se/piece_i.wav",
J = love.audio.newSource("res/se/piece_j.wav", "static"), J = "res/se/piece_j.wav",
L = love.audio.newSource("res/se/piece_l.wav", "static"), L = "res/se/piece_l.wav",
O = love.audio.newSource("res/se/piece_o.wav", "static"), O = "res/se/piece_o.wav",
S = love.audio.newSource("res/se/piece_s.wav", "static"), S = "res/se/piece_s.wav",
T = love.audio.newSource("res/se/piece_t.wav", "static"), T = "res/se/piece_t.wav",
Z = love.audio.newSource("res/se/piece_z.wav", "static") Z = "res/se/piece_z.wav"
}, },
move = love.audio.newSource("res/se/move.wav", "static"), move = "res/se/move.wav",
bottom = love.audio.newSource("res/se/bottom.wav", "static"), rotate = "res/se/rotate.wav",
cursor = love.audio.newSource("res/se/cursor.wav", "static"), kick = "res/se/kick.wav",
cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"), bottom = "res/se/bottom.wav",
main_decide = love.audio.newSource("res/se/main_decide.wav", "static"), cursor = "res/se/cursor.wav",
mode_decide = love.audio.newSource("res/se/mode_decide.wav", "static"), cursor_lr = "res/se/cursor_lr.wav",
lock = love.audio.newSource("res/se/lock.wav", "static"), main_decide = "res/se/main_decide.wav",
hold = love.audio.newSource("res/se/hold.wav", "static"), mode_decide = "res/se/mode_decide.wav",
erase = love.audio.newSource("res/se/erase.wav", "static"), lock = "res/se/lock.wav",
fall = love.audio.newSource("res/se/fall.wav", "static"), hold = "res/se/hold.wav",
ready = love.audio.newSource("res/se/ready.wav", "static"), erase = {
go = love.audio.newSource("res/se/go.wav", "static"), single = "res/se/single.wav",
irs = love.audio.newSource("res/se/irs.wav", "static"), double = "res/se/double.wav",
ihs = love.audio.newSource("res/se/ihs.wav", "static"), 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! -- a secret sound!
welcome = love.audio.newSource("res/se/welcomeToCambridge.wav", "static"), welcome = "res/se/welcomeToCambridge.wav",
} }
-- 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(sounds) do
if(type(v) == "table") then
-- list of subsounds
for k2,v2 in pairs(v) do
if(love.filesystem.getInfo(sounds[k][k2])) then
-- this file exists
sounds[k][k2] = love.audio.newSource(sounds[k][k2], "static")
else
sounds[k][k2] = nil
end
end
else
if(love.filesystem.getInfo(sounds[k])) then
-- this file exists
print("Successfully converted " .. v)
sounds[k] = love.audio.newSource(sounds[k], "static")
else
sounds[k] = nil
end
end
end
function playSE(sound, subsound) function playSE(sound, subsound)
if sound ~= nil then if sound ~= nil then
if subsound ~= nil then if sounds[sound] then
sounds[sound][subsound]:setVolume(config.sfx_volume) if subsound ~= nil then
if sounds[sound][subsound]:isPlaying() then if sounds[sound][subsound] then
sounds[sound][subsound]:stop() 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 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 end
end end
function playSEOnce(sound, subsound) function playSEOnce(sound, subsound)
if sound ~= nil then if sound ~= nil then
if subsound ~= nil then if sounds[sound] then
sounds[sound][subsound]:setVolume(config.sfx_volume) if subsound ~= nil then
if sounds[sound][subsound]:isPlaying() then if sounds[sound][subsound] then
return 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 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 end
end end

BIN
res/se/double.wav Normal file

Binary file not shown.

BIN
res/se/quad.wav Normal file

Binary file not shown.

BIN
res/se/single.wav Normal file

Binary file not shown.

BIN
res/se/triple.wav Normal file

Binary file not shown.

View File

@ -269,7 +269,8 @@ function GameMode:update(inputs, ruleset)
end end
if cleared_row_count > 0 then 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.lcd = self:getLineClearDelay()
self.last_lcd = self.lcd self.last_lcd = self.lcd
self.are = ( self.are = (

View File

@ -100,10 +100,12 @@ function Ruleset:attemptRotate(new_inputs, piece, grid, initial)
if (grid:canPlacePiece(new_piece)) then if (grid:canPlacePiece(new_piece)) then
piece:setRelativeRotation(rot_dir) piece:setRelativeRotation(rot_dir)
self:onPieceRotate(piece, grid) self:onPieceRotate(piece, grid)
playSE("rotate")
else else
if not(initial and self.enable_IRS_wallkicks == false) then if not(initial and self.enable_IRS_wallkicks == false) then
self:attemptWallkicks(piece, new_piece, rot_dir, grid) self:attemptWallkicks(piece, new_piece, rot_dir, grid)
end end
playSE("kick")
end end
end end