mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 18:39:02 -06:00
Game over animation (customizable per mode)
This commit is contained in:
parent
a33ca1af24
commit
e20eb048c8
@ -104,6 +104,12 @@ function GameScene:render()
|
|||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
if self.paused then love.graphics.print("PAUSED!", 80, 100) end
|
if self.paused then love.graphics.print("PAUSED!", 80, 100) end
|
||||||
|
|
||||||
|
if self.game.completed then
|
||||||
|
self.game:onGameComplete()
|
||||||
|
elseif self.game.game_over then
|
||||||
|
self.game:onGameOver()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:onInputPress(e)
|
function GameScene:onInputPress(e)
|
||||||
|
@ -109,7 +109,8 @@ end
|
|||||||
|
|
||||||
function GameMode:update(inputs, ruleset)
|
function GameMode:update(inputs, ruleset)
|
||||||
if self.game_over or self.completed then
|
if self.game_over or self.completed then
|
||||||
self:onGameOver()
|
switchBGM(nil)
|
||||||
|
self.game_over_frames = self.game_over_frames + 1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -210,18 +211,15 @@ function GameMode:update(inputs, ruleset)
|
|||||||
|
|
||||||
if self.piece.locked == true then
|
if self.piece.locked == true then
|
||||||
self.grid:applyPiece(self.piece)
|
self.grid:applyPiece(self.piece)
|
||||||
|
|
||||||
if self.square_mode then
|
if self.square_mode then
|
||||||
self.squares = self.squares + self.grid:markSquares()
|
self.squares = self.squares + self.grid:markSquares()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.grid:markClearedRows()
|
|
||||||
|
|
||||||
local cleared_row_count = self.grid:getClearedRowCount()
|
local cleared_row_count = self.grid:getClearedRowCount()
|
||||||
|
|
||||||
self:onPieceLock(self.piece, cleared_row_count)
|
self:onPieceLock(self.piece, cleared_row_count)
|
||||||
self:updateScore(self.level, self.drop_bonus, cleared_row_count)
|
self:updateScore(self.level, self.drop_bonus, cleared_row_count)
|
||||||
|
|
||||||
|
self.grid:markClearedRows()
|
||||||
self.piece = nil
|
self.piece = nil
|
||||||
if self.enable_hold then
|
if self.enable_hold then
|
||||||
self.held = false
|
self.held = false
|
||||||
@ -284,7 +282,15 @@ function GameMode:onHardDrop(dropped_row_count)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:onGameOver()
|
function GameMode:onGameOver()
|
||||||
switchBGM(nil)
|
love.graphics.setColor(0, 0, 0, 1 - 2 ^ (-self.game_over_frames / 30))
|
||||||
|
love.graphics.rectangle(
|
||||||
|
"fill", 64, 80,
|
||||||
|
16 * self.grid.width, 16 * (self.grid.height - 4)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameMode:onGameComplete()
|
||||||
|
self:onGameOver()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- DAS functions
|
-- DAS functions
|
||||||
@ -422,7 +428,6 @@ function GameMode:initializeOrHold(inputs, ruleset)
|
|||||||
end
|
end
|
||||||
self:onPieceEnter()
|
self:onPieceEnter()
|
||||||
if not self.grid:canPlacePiece(self.piece) then
|
if not self.grid:canPlacePiece(self.piece) then
|
||||||
self:onGameOver()
|
|
||||||
self.game_over = true
|
self.game_over = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user