Compare commits

..

2 Commits

Author SHA1 Message Date
Ishaan Bhardwaj
61de3c6dbf Miscellaneous fixes to piece behavior in addition to fixing prev. commit 2021-06-26 16:27:33 -04:00
Ishaan Bhardwaj
3c718c38e4 Revert "Fixed a bug where pieces would check gravity before a block out"
This reverts commit d18c3e298d.
2021-06-26 14:55:18 -04:00
3 changed files with 19 additions and 19 deletions

View File

@ -45,7 +45,9 @@ function GameScene:render()
self.game:drawBackground()
self.game:drawFrame()
self.game:drawGrid()
if self.game.lcd > 0 then self.game:drawLineClearAnimation() end
if self.game:canDrawLCA() then
self.game:drawLineClearAnimation()
end
self.game:drawPiece()
self.game:drawNextQueue(self.ruleset)
self.game:drawScoringInfo()

View File

@ -156,9 +156,6 @@ function GameMode:update(inputs, ruleset)
if self.enable_hold and inputs["hold"] == true and self.held == false and self.prev_inputs["hold"] == false then
self:hold(inputs, ruleset)
self.prev_inputs = inputs
if not self.grid:canPlacePiece(self.piece) then
self.game_over = true
end
return
end
@ -498,6 +495,10 @@ function GameMode:initializeOrHold(inputs, ruleset)
if not self.grid:canPlacePiece(self.piece) then
self.game_over = true
end
ruleset:dropPiece(
inputs, self.piece, self.grid, self:getGravity(),
self:getDropSpeed(), self.drop_locked, self.hard_drop_locked
)
end
function GameMode:hold(inputs, ruleset, ihs)
@ -522,17 +523,19 @@ function GameMode:hold(inputs, ruleset, ihs)
if ihs then playSE("ihs")
else playSE("hold") end
self:onHold()
if not self.grid:canPlacePiece(self.piece) then
self.game_over = true
end
end
function GameMode:initializeNextPiece(inputs, ruleset, piece_data, generate_next_piece)
self.piece_hard_dropped = false
self.piece_soft_locked = false
local gravity = self:getGravity()
self.piece = ruleset:initializePiece(
inputs, piece_data, self.grid, gravity,
inputs, piece_data, self.grid, self:getGravity(),
self.prev_inputs, self.move,
self:getLockDelay(), self:getDropSpeed(),
self.lock_drop, self.lock_hard_drop, self.big_mode,
self.drop_locked, self.hard_drop_locked, self.big_mode,
(
self.frames == 0 or (ruleset.are and self:getARE() ~= 0)
) and self.irs or false
@ -607,6 +610,10 @@ function GameMode:animation(x, y, skin, colour)
}
end
function GameMode:canDrawLCA()
return self.lcd > 0
end
function GameMode:drawLineClearAnimation()
-- animation function
-- params: block x, y, skin, colour

View File

@ -221,16 +221,7 @@ function Ruleset:initializePiece(
colours = self.colourscheme
end
local spawn_x
if (grid.width ~= 10) then
local percent = spawn_positions[data.shape].x / 10
for i = grid.width - 1, 0, -1 do
if i / grid.width <= percent then
spawn_x = i
break
end
end
end
local spawn_x = math.floor(spawn_positions[data.shape].x / 10 * grid.width)
local spawn_dy
if (config.gamesettings.spawn_positions == 1) then
@ -275,9 +266,9 @@ function Ruleset:processPiece(
if synchroes_allowed then
self:rotatePiece(inputs, piece, grid, prev_inputs, false)
self:movePiece(piece, grid, move, gravity >= 20)
self:movePiece(piece, grid, move, gravity >= grid.height - 4)
else
self:movePiece(piece, grid, move, gravity >= 20)
self:movePiece(piece, grid, move, gravity >= grid.height - 4)
self:rotatePiece(inputs, piece, grid, prev_inputs, false)
end
self:dropPiece(