Add new sound effects to the game

This commit is contained in:
Mizu 2020-10-26 14:21:49 +01:00
parent 9fca272e8d
commit b0ce0f17f5
9 changed files with 30 additions and 1 deletions

View File

@ -14,6 +14,11 @@ sounds = {
cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"), cursor_lr = love.audio.newSource("res/se/cursor_lr.wav", "static"),
main_decide = love.audio.newSource("res/se/main_decide.wav", "static"), main_decide = love.audio.newSource("res/se/main_decide.wav", "static"),
mode_decide = love.audio.newSource("res/se/mode_decide.wav", "static"), mode_decide = love.audio.newSource("res/se/mode_decide.wav", "static"),
lock = love.audio.newSource("res/se/lock.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"),
} }
function playSE(sound, subsound) function playSE(sound, subsound)
@ -31,3 +36,19 @@ function playSE(sound, subsound)
sounds[sound][subsound]:play() sounds[sound][subsound]:play()
end end
end end
function playSEOnce(sound, subsound)
if subsound == nil then
sounds[sound]:setVolume(0.1)
if sounds[sound]:isPlaying() then
return
end
sounds[sound]:play()
else
sounds[sound][subsound]:setVolume(0.1)
if sounds[sound][subsound]:isPlaying() then
return
end
sounds[sound][subsound]:play()
end
end

Binary file not shown.

BIN
res/se/erase.wav Normal file

Binary file not shown.

BIN
res/se/fall.wav Normal file

Binary file not shown.

BIN
res/se/go.wav Normal file

Binary file not shown.

BIN
res/se/lock.wav Normal file

Binary file not shown.

BIN
res/se/ready.wav Normal file

Binary file not shown.

View File

@ -51,8 +51,10 @@ function GameScene:render()
-- ready/go graphics -- ready/go graphics
if self.game.ready_frames <= 100 and self.game.ready_frames > 52 then if self.game.ready_frames <= 100 and self.game.ready_frames > 52 then
love.graphics.draw(misc_graphics["ready"], 144 - 50, 240 - 14) love.graphics.draw(misc_graphics["ready"], 144 - 50, 240 - 14)
playSEOnce("ready")
elseif self.game.ready_frames <= 50 and self.game.ready_frames > 2 then elseif self.game.ready_frames <= 50 and self.game.ready_frames > 2 then
love.graphics.draw(misc_graphics["go"], 144 - 27, 240 - 14) love.graphics.draw(misc_graphics["go"], 144 - 27, 240 - 14)
playSEOnce("go")
end end
self.game:drawCustom() self.game:drawCustom()

View File

@ -161,6 +161,7 @@ function GameMode:update(inputs, ruleset)
end end
if cleared_row_count > 0 then if cleared_row_count > 0 then
playSE("erase")
self.lcd = self:getLineClearDelay() self.lcd = self:getLineClearDelay()
self.are = self:getLineARE() self.are = self:getLineARE()
if self.lcd == 0 then if self.lcd == 0 then
@ -194,8 +195,12 @@ end
-- event functions -- event functions
function GameMode:whilePieceActive() end function GameMode:whilePieceActive() end
function GameMode:onPieceLock(piece, cleared_row_count) end function GameMode:onPieceLock(piece, cleared_row_count)
playSE("lock")
end
function GameMode:onLineClear(cleared_row_count) end function GameMode:onLineClear(cleared_row_count) end
function GameMode:onPieceEnter() end function GameMode:onPieceEnter() end
function GameMode:onHold() end function GameMode:onHold() end
@ -248,6 +253,7 @@ function GameMode:processDelays(inputs, ruleset, drop_speed)
self.lcd = self.lcd - 1 self.lcd = self.lcd - 1
if self.lcd == 0 then if self.lcd == 0 then
self.grid:clearClearedRows() self.grid:clearClearedRows()
playSE("fall")
if self.are == 0 then if self.are == 0 then
self:initializeOrHold(inputs, ruleset) self:initializeOrHold(inputs, ruleset)
end end