2019-05-22 22:57:34 -05:00
|
|
|
require 'funcs'
|
|
|
|
|
|
|
|
local GameMode = require 'tetris.modes.gamemode'
|
|
|
|
local Piece = require 'tetris.components.piece'
|
|
|
|
|
2020-10-08 22:34:11 -05:00
|
|
|
local Bag7NoSZOStartRandomizer = require 'tetris.randomizers.bag7noSZOstart'
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
local SurvivalAXGame = GameMode:extend()
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
SurvivalAXGame.name = "Survival AX"
|
|
|
|
SurvivalAXGame.hash = "SurvivalAX"
|
|
|
|
SurvivalAXGame.tagline = "Can you clear the time hurdles when the game goes this fast?"
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2019-05-29 20:59:53 -05:00
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:new()
|
|
|
|
SurvivalAXGame.super:new()
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2020-10-08 22:34:11 -05:00
|
|
|
self.randomizer = Bag7NoSZOStartRandomizer()
|
2019-05-22 22:57:34 -05:00
|
|
|
|
|
|
|
self.section_time_limit = 3600
|
|
|
|
self.section_start_time = 0
|
|
|
|
self.section_times = { [0] = 0 }
|
|
|
|
self.section_clear = false
|
|
|
|
|
|
|
|
self.lock_drop = true
|
2020-11-10 22:13:25 -06:00
|
|
|
self.lock_hard_drop = true
|
2019-05-22 22:57:34 -05:00
|
|
|
self.enable_hold = true
|
|
|
|
self.next_queue_length = 3
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getARE()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.lines < 10 then return 18
|
2019-05-22 22:57:34 -05:00
|
|
|
elseif self.lines < 40 then return 14
|
|
|
|
elseif self.lines < 60 then return 12
|
|
|
|
elseif self.lines < 70 then return 10
|
|
|
|
elseif self.lines < 80 then return 8
|
|
|
|
elseif self.lines < 90 then return 7
|
|
|
|
else return 6 end
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getLineARE()
|
2019-05-22 22:57:34 -05:00
|
|
|
return self:getARE()
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getDasLimit()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.lines < 20 then return 10
|
2019-05-22 22:57:34 -05:00
|
|
|
elseif self.lines < 50 then return 9
|
|
|
|
elseif self.lines < 70 then return 8
|
|
|
|
else return 7 end
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getLineClearDelay()
|
2020-11-06 19:49:44 -06:00
|
|
|
if self.lines < 10 then return 14
|
2019-05-22 22:57:34 -05:00
|
|
|
elseif self.lines < 30 then return 9
|
|
|
|
else return 5 end
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getLockDelay()
|
2019-05-22 22:57:34 -05:00
|
|
|
if self.lines < 10 then return 28
|
|
|
|
elseif self.lines < 20 then return 24
|
|
|
|
elseif self.lines < 30 then return 22
|
|
|
|
elseif self.lines < 40 then return 20
|
|
|
|
elseif self.lines < 50 then return 18
|
|
|
|
elseif self.lines < 70 then return 14
|
|
|
|
else return 13 end
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getGravity()
|
2019-05-22 22:57:34 -05:00
|
|
|
return 20
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getSection()
|
2019-05-22 22:57:34 -05:00
|
|
|
return math.floor(level / 100) + 1
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:advanceOneFrame()
|
2021-03-07 08:49:07 -06:00
|
|
|
if self.ready_frames == 0 then
|
2019-05-22 22:57:34 -05:00
|
|
|
if not self.section_clear then
|
|
|
|
self.frames = self.frames + 1
|
|
|
|
end
|
|
|
|
if self:getSectionTime() >= self.section_time_limit then
|
|
|
|
self.game_over = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:onLineClear(cleared_row_count)
|
2019-05-22 22:57:34 -05:00
|
|
|
if not self.clear then
|
|
|
|
local new_lines = self.lines + cleared_row_count
|
|
|
|
self:updateSectionTimes(self.lines, new_lines)
|
|
|
|
self.lines = math.min(new_lines, 150)
|
|
|
|
if self.lines == 150 then
|
2020-11-01 10:06:43 -06:00
|
|
|
self.grid:clear()
|
2019-05-22 22:57:34 -05:00
|
|
|
self.clear = true
|
2021-03-07 08:49:07 -06:00
|
|
|
self.completed = true
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getSectionTime()
|
2019-05-22 22:57:34 -05:00
|
|
|
return self.frames - self.section_start_time
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:updateSectionTimes(old_lines, new_lines)
|
2019-05-22 22:57:34 -05:00
|
|
|
if math.floor(old_lines / 10) < math.floor(new_lines / 10) then
|
|
|
|
-- record new section
|
|
|
|
table.insert(self.section_times, self:getSectionTime())
|
|
|
|
self.section_start_time = self.frames
|
|
|
|
self.section_clear = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:onPieceEnter()
|
2019-05-22 22:57:34 -05:00
|
|
|
self.section_clear = false
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:drawGrid(ruleset)
|
2019-05-22 22:57:34 -05:00
|
|
|
self.grid:draw()
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getHighscoreData()
|
2019-05-22 22:57:34 -05:00
|
|
|
return {
|
|
|
|
lines = self.lines,
|
|
|
|
frames = self.frames,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:drawScoringInfo()
|
|
|
|
SurvivalAXGame.super.drawScoringInfo(self)
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2021-10-19 19:37:48 -05:00
|
|
|
if config["side_next"] then
|
|
|
|
love.graphics.printf("NEXT", 240, 72, 40, "left")
|
|
|
|
else
|
|
|
|
love.graphics.printf("NEXT", 64, 40, 40, "left")
|
|
|
|
end
|
2019-05-22 22:57:34 -05:00
|
|
|
|
2021-10-19 19:37:48 -05:00
|
|
|
local text_x = config["side_next"] and 316 or 240
|
|
|
|
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.setFont(font_3x5_2)
|
|
|
|
love.graphics.print(
|
|
|
|
self.das.direction .. " " ..
|
|
|
|
self.das.frames .. " " ..
|
2020-10-06 12:14:00 -05:00
|
|
|
strTrueValues(self.prev_inputs)
|
2019-05-22 22:57:34 -05:00
|
|
|
)
|
2020-11-22 09:39:42 -06:00
|
|
|
if self.lines < 150 then love.graphics.printf("TIME LEFT", 240, 250, 80, "left") end
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.printf("LINES", 240, 320, 40, "left")
|
|
|
|
|
|
|
|
local current_section = math.floor(self.lines / 10) + 1
|
|
|
|
self:drawSectionTimesWithSplits(current_section)
|
|
|
|
|
|
|
|
love.graphics.setFont(font_3x5_3)
|
|
|
|
love.graphics.printf(self.lines, 240, 340, 40, "right")
|
|
|
|
love.graphics.printf(self.clear and self.lines or self:getSectionEndLines(), 240, 370, 40, "right")
|
|
|
|
|
|
|
|
-- draw time left, flash red if necessary
|
|
|
|
local time_left = self.section_time_limit - math.max(self:getSectionTime(), 0)
|
2020-10-06 12:14:00 -05:00
|
|
|
if not self.game_over and not self.clear and time_left < frameTime(0,10) and time_left % 4 < 2 then
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.setColor(1, 0.3, 0.3, 1)
|
|
|
|
end
|
2020-11-22 09:39:42 -06:00
|
|
|
if self.lines < 150 then love.graphics.printf(formatTime(time_left), 240, 270, 160, "left") end
|
2019-05-22 22:57:34 -05:00
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getSectionEndLines()
|
2019-05-22 22:57:34 -05:00
|
|
|
return math.floor(self.lines / 10 + 1) * 10
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
function SurvivalAXGame:getBackground()
|
2019-05-22 22:57:34 -05:00
|
|
|
return math.floor(self.lines / 10)
|
|
|
|
end
|
|
|
|
|
2020-12-02 23:26:36 -06:00
|
|
|
return SurvivalAXGame
|