From 452879ebab82945cb4bde15d5ea91667165dd579 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Wed, 20 Jan 2021 10:53:22 -0500 Subject: [PATCH] Fixed Marathon A3 section times, read comments Some modes may not launch currently, will fix --- tetris/modes/gamemode.lua | 8 +++++--- tetris/modes/marathon_a3.lua | 12 +++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tetris/modes/gamemode.lua b/tetris/modes/gamemode.lua index 95a0686..d19edb2 100644 --- a/tetris/modes/gamemode.lua +++ b/tetris/modes/gamemode.lua @@ -109,7 +109,6 @@ end function GameMode:update(inputs, ruleset) if self.game_over or self.completed then - switchBGM(nil) self.game_over_frames = self.game_over_frames + 1 return end @@ -282,6 +281,7 @@ function GameMode:onHardDrop(dropped_row_count) end function GameMode:onGameOver() + switchBGM(nil) love.graphics.setColor(0, 0, 0, 1 - 2 ^ (-self.game_over_frames / 30)) love.graphics.rectangle( "fill", 64, 80, @@ -602,7 +602,7 @@ function GameMode:sectionColourFunction(section) return { 1, 1, 1, 1 } end -function GameMode:drawSectionTimesWithSecondary(current_section) +function GameMode:drawSectionTimesWithSecondary(current_section, section_limit) local section_x = 530 local section_secondary_x = 440 @@ -627,7 +627,9 @@ function GameMode:drawSectionTimesWithSecondary(current_section) current_x = section_secondary_x end - love.graphics.printf(formatTime(self.frames - self.section_start_time), current_x, 40 + 20 * current_section, 90, "left") + if current_section <= section_limit then + love.graphics.printf(formatTime(self.frames - self.section_start_time), current_x, 40 + 20 * current_section, 90, "left") + end end function GameMode:drawSectionTimesWithSplits(current_section) diff --git a/tetris/modes/marathon_a3.lua b/tetris/modes/marathon_a3.lua index 2acd190..c8c4c44 100644 --- a/tetris/modes/marathon_a3.lua +++ b/tetris/modes/marathon_a3.lua @@ -30,6 +30,7 @@ function MarathonA3Game:new() self.secondary_section_times = { [0] = 0 } self.section_times = { [0] = 0 } self.section_cool = false + self.piece_active_time = 0 self.randomizer = History6RollsRandomizer() @@ -147,7 +148,12 @@ function MarathonA3Game:advanceOneFrame() return true end +function MarathonA3Game:whilePieceActive() + self.piece_active_time = self.piece_active_time + 1 +end + function MarathonA3Game:onPieceEnter() + self.piece_active_time = 0 if (self.level % 100 ~= 99) and self.level ~= 998 and self.frames ~= 0 then self:updateSectionTimes(self.level, self.level + 1) self.level = self.level + 1 @@ -315,7 +321,7 @@ local grade_conversion = { function MarathonA3Game:updateGrade(cleared_lines) if cleared_lines == 0 then - self.grade_point_decay_counter = self.grade_point_decay_counter + 1 + self.grade_point_decay_counter = self.grade_point_decay_counter + self.piece_active_time if self.grade_point_decay_counter >= grade_point_decays[self.grade + 1] then self.grade_point_decay_counter = 0 self.grade_points = math.max(0, self.grade_points - 1) @@ -424,8 +430,8 @@ function MarathonA3Game:drawScoringInfo() end -- draw section time data - current_section = math.floor(self.level / 100) + 1 - self:drawSectionTimesWithSecondary(current_section) + current_section = self.level >= 999 and 11 or math.floor(self.level / 100) + 1 + self:drawSectionTimesWithSecondary(current_section, 10) --[[ section_x = 530