From 8cf4328264ba3021d0841a00f6541c5489b0c77f Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Tue, 5 Jan 2021 22:03:10 -0500 Subject: [PATCH] Classic mode updates C88: Select a gravity multiplier up to 4x C89: Menu --- tetris/modes/marathon_c88.lua | 50 ++++++++++++++++++++++++----------- tetris/modes/marathon_c89.lua | 37 +++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 18 deletions(-) diff --git a/tetris/modes/marathon_c88.lua b/tetris/modes/marathon_c88.lua index 20e3e81..81cf50d 100644 --- a/tetris/modes/marathon_c88.lua +++ b/tetris/modes/marathon_c88.lua @@ -11,7 +11,7 @@ MarathonC88Game.name = "Marathon C88" MarathonC88Game.hash = "MarathonC88" MarathonC88Game.tagline = "An old Japanese game! Can you hit the max score?" -function MarathonC88Game:new() +function MarathonC88Game:new(secret_inputs) self.super:new() self.level_timer = 0 @@ -19,6 +19,16 @@ function MarathonC88Game:new() self.tetrises = 0 self.line_clears = 0 + if secret_inputs.rotate_left and secret_inputs.rotate_right then + self.gravity_multiplier = 4 + elseif secret_inputs.rotate_left then + self.gravity_multiplier = 2 + elseif secret_inputs.rotate_right then + self.gravity_multiplier = 3 + else + self.gravity_multiplier = 1 + end + self.randomizer = SegaRandomizer() self.lock_drop = false @@ -52,20 +62,24 @@ function MarathonC88Game:getLineClearDelay() return 42 end function MarathonC88Game:getLockDelay() return 30 end function MarathonC88Game:getGravity() - if self.level == 0 then return 1/30 - elseif self.level == 1 then return 1/15 - elseif self.level == 2 then return 1/12 - elseif self.level == 3 then return 1/10 - elseif self.level == 4 then return 1/8 - elseif self.level == 5 then return 1/6 - elseif self.level == 6 then return 1/4 - elseif self.level == 7 then return 1/2 - elseif self.level <= 9 then return 1 - elseif self.level == 10 then return 1/8 - elseif self.level == 11 then return 1/6 - elseif self.level == 12 then return 1/4 - elseif self.level == 13 then return 1/2 - else return 1 end + local gravity + + if self.level == 0 then gravity = 1/30 + elseif self.level == 1 then gravity = 1/15 + elseif self.level == 2 then gravity = 1/12 + elseif self.level == 3 then gravity = 1/10 + elseif self.level == 4 then gravity = 1/8 + elseif self.level == 5 then gravity = 1/6 + elseif self.level == 6 then gravity = 1/4 + elseif self.level == 7 then gravity = 1/2 + elseif self.level <= 9 then gravity = 1 + elseif self.level == 10 then gravity = 1/8 + elseif self.level == 11 then gravity = 1/6 + elseif self.level == 12 then gravity = 1/4 + elseif self.level == 13 then gravity = 1/2 + else gravity = 1 end + + return gravity * self.gravity_multiplier end function MarathonC88Game:getLevelTimerLimit() @@ -129,6 +143,12 @@ function MarathonC88Game:drawScoringInfo() love.graphics.printf("SCORE", 240, 120, 40, "left") love.graphics.printf("LINES", 240, 200, 40, "left") love.graphics.printf("LEVEL", 240, 280, 40, "left") + if self.gravity_multiplier ~= 1 then + love.graphics.printf( + self.gravity_multiplier .. "x GRAVITY ACTIVE!", + 240, 350, 150, "left" + ) + end love.graphics.setFont(font_3x5_3) if self.score >= 999999 then love.graphics.setColor(1, 1, 0, 1) end diff --git a/tetris/modes/marathon_c89.lua b/tetris/modes/marathon_c89.lua index d9bfab9..03bf4e6 100644 --- a/tetris/modes/marathon_c89.lua +++ b/tetris/modes/marathon_c89.lua @@ -19,6 +19,7 @@ function MarathonC89Game:new() self.ready_frames = 1 self.waiting_frames = 96 + self.in_menu = true self.start_level = 18 self.level = self.start_level @@ -126,8 +127,19 @@ function MarathonC89Game:getGravity() else return gravity_table[self.level] end end -function MarathonC89Game:advanceOneFrame() - if self.waiting_frames > 0 then +function MarathonC89Game:advanceOneFrame(inputs, ruleset) + if self.in_menu then + if not self.prev_inputs["right"] and inputs["right"] then + self.start_level = math.min(29, self.start_level + 1) + elseif not self.prev_inputs["left"] and inputs["left"] then + self.start_level = math.max(0, self.start_level - 1) + elseif inputs["hold"] then + self.in_menu = false + end + self.level = self.start_level + self.prev_inputs = copy(inputs) + return false + elseif self.waiting_frames > 0 then self.waiting_frames = self.waiting_frames - 1 else self.frames = self.frames + 1 @@ -195,9 +207,28 @@ function MarathonC89Game:drawScoringInfo() love.graphics.printf(formatTime(self.frames), 64, 420, 160, "center") end +function MarathonC89Game:drawCustom() + love.graphics.setColor(1, 1, 1, 1) + + if self.in_menu then + love.graphics.setFont(font_3x5_3) + love.graphics.printf("CHOOSE A LEVEL", 64, 120, 160, "center") + + love.graphics.setFont(font_3x5_4) + love.graphics.printf( + (self.start_level == 0 and "-- " or "<- ") .. + (self.start_level <= 9 and 0 .. self.start_level or self.start_level) .. + (self.start_level == 29 and " --" or " ->"), + 64, 200, 160, "center" + ) + + love.graphics.setFont(font_3x5_2) + love.graphics.printf("Press hold to start", 64, 260, 160, "center") + end +end function MarathonC89Game:getBackground() - return math.min(self.level, 19) + return self.level % 20 end function MarathonC89Game:getHighscoreData()