From bc50d75b9a8b214b3093cb575575b7e0a7476ccd Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sat, 27 Nov 2021 16:09:41 -0500 Subject: [PATCH] Fixed GTE spawn logic --- tetris/modes/survival_gte.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tetris/modes/survival_gte.lua b/tetris/modes/survival_gte.lua index d834c77..30fb364 100644 --- a/tetris/modes/survival_gte.lua +++ b/tetris/modes/survival_gte.lua @@ -56,6 +56,25 @@ function SurvivalGTEGame:onLineClear(cleared_row_count) self.completed = self.lines >= 300 end +local function getLowestBlockY(offsets) + local res = -math.huge + for _, o in pairs(offsets) do + if o.y > res then + res = o.y + end + end + return res +end + +function SurvivalGTEGame:onEnterOrHold(...) + while ( + getLowestBlockY(self.piece:getBlockOffsets()) + self.piece.position.y + ) < 4 do + self.piece.position.y = self.piece.position.y + 1 + end + self.super.onEnterOrHold(self, ...) +end + function SurvivalGTEGame:advanceOneFrame() if self.ready_frames == 0 then self.frames = self.frames + 1