From af02cd34672815a7a9980e543ac8bc862ab69725 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Thu, 11 Feb 2021 15:46:56 -0500 Subject: [PATCH] Classic lock (GB/NES-like) added as a gamemode var --- tetris/modes/gamemode.lua | 18 +++++++++++------- tetris/rulesets/ruleset.lua | 11 +++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tetris/modes/gamemode.lua b/tetris/modes/gamemode.lua index 95cc4ff..469b16e 100644 --- a/tetris/modes/gamemode.lua +++ b/tetris/modes/gamemode.lua @@ -45,6 +45,7 @@ function GameMode:new(secret_inputs) self.enable_hard_drop = true self.next_queue_length = 1 self.additive_gravity = true + self.classic_lock = false self.draw_section_times = false self.draw_secondary_section_times = false self.big_mode = false @@ -194,7 +195,7 @@ function GameMode:update(inputs, ruleset) inputs, self.piece, self.grid, self:getGravity(), self.prev_inputs, self.move, self:getLockDelay(), self:getDropSpeed(), self.drop_locked, self.hard_drop_locked, - self.enable_hard_drop, self.additive_gravity + self.enable_hard_drop, self.additive_gravity, self.classic_lock ) local piece_dy = self.piece.position.y - piece_y @@ -578,7 +579,7 @@ function GameMode:drawLineClearAnimation() -- TGM1 pop-out --[[ function animation(x, y, skin, colour) - local p = 0.48 + local p = 0.5 local l = ( (self:getLineClearDelay() - self.lcd) / self:getLineClearDelay() ) @@ -609,12 +610,15 @@ end function GameMode:drawPiece() if self.piece ~= nil then - self.piece:draw( - 1, - self:getLockDelay() == 0 and 1 or - (0.25 + 0.75 * math.max(1 - self.piece.gravity, 1 - (self.piece.lock_delay / self:getLockDelay()))), - self.grid + local b = ( + self.classic_lock and + ( + self.piece:isDropBlocked(self.grid) and + 1 - self.piece.gravity or 1 + ) or + 1 - (self.piece.lock_delay / self:getLockDelay()) ) + self.piece:draw(1, 0.25 + 0.75 * b, self.grid) end end diff --git a/tetris/rulesets/ruleset.lua b/tetris/rulesets/ruleset.lua index 42a024c..fc3de20 100644 --- a/tetris/rulesets/ruleset.lua +++ b/tetris/rulesets/ruleset.lua @@ -209,8 +209,11 @@ function Ruleset:dropPiece( end end -function Ruleset:lockPiece(piece, grid, lock_delay) - if piece:isDropBlocked(grid) and piece.gravity >= 1 and piece.lock_delay >= lock_delay then +function Ruleset:lockPiece(piece, grid, lock_delay, classic_lock) + if piece:isDropBlocked(grid) and ( + (classic_lock and piece.gravity >= 1) or + (not classic_lock and piece.lock_delay >= lock_delay) + ) then piece.locked = true end end @@ -286,7 +289,7 @@ function Ruleset:processPiece( inputs, piece, grid, gravity, prev_inputs, move, lock_delay, drop_speed, drop_locked, hard_drop_locked, - hard_drop_enabled, additive_gravity + hard_drop_enabled, additive_gravity, classic_lock ) local synchroes_allowed = ({not self.world, true, false})[config.gamesettings.synchroes_allowed] @@ -302,7 +305,7 @@ function Ruleset:processPiece( inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked, hard_drop_enabled, additive_gravity ) - self:lockPiece(piece, grid, lock_delay) + self:lockPiece(piece, grid, lock_delay, classic_lock) end function Ruleset:onPieceMove(piece) end