diff --git a/scene/mode_select.lua b/scene/mode_select.lua index 46c3714..a2e1efd 100644 --- a/scene/mode_select.lua +++ b/scene/mode_select.lua @@ -13,6 +13,7 @@ game_modes = { require 'tetris.modes.strategy', require 'tetris.modes.interval_training', require 'tetris.modes.pacer_test', + require 'tetris.modes.marathon_wcb', require 'tetris.modes.demon_mode', require 'tetris.modes.phantom_mania', require 'tetris.modes.phantom_mania2', diff --git a/tetris/modes/gamemode.lua b/tetris/modes/gamemode.lua index 8b9d223..f437d2b 100644 --- a/tetris/modes/gamemode.lua +++ b/tetris/modes/gamemode.lua @@ -95,6 +95,16 @@ function GameMode:update(inputs, ruleset) self:chargeDAS(inputs, self:getDasLimit(), self.getARR()) + -- set attempt flags + if inputs["left"] or inputs["right"] then self:onAttemptPieceMove(self.piece) end + if + inputs["rotate_left"] or inputs["rotate_right"] or + inputs["rotate_left2"] or inputs["rotate_right2"] or + inputs["rotate_180"] + then + self:onAttemptPieceRotate(self.piece) + end + if self.piece == nil then self:processDelays(inputs, ruleset) else @@ -198,6 +208,8 @@ end -- event functions function GameMode:whilePieceActive() end +function GameMode:onAttemptPieceMove(piece) end +function GameMode:onAttemptPieceRotate(piece) end function GameMode:onPieceLock(piece, cleared_row_count) end function GameMode:onLineClear(cleared_row_count) end function GameMode:onPieceEnter() end @@ -220,11 +232,17 @@ end function GameMode:startRightDAS() self.move = "right" self.das = { direction = "right", frames = 0 } + if self:getDasLimit() == 0 then + self:continueDAS() + end end function GameMode:startLeftDAS() self.move = "left" self.das = { direction = "left", frames = 0 } + if self:getDasLimit() == 0 then + self:continueDAS() + end end function GameMode:continueDAS() @@ -300,7 +318,6 @@ function GameMode:initializeOrHold(inputs, ruleset) else self:initializeNextPiece(inputs, ruleset, self.next_queue[1]) end - self:onPieceEnter() if not self.grid:canPlacePiece(self.piece) then self:onGameOver() self.game_over = true diff --git a/tetris/modes/marathon_wcb.lua b/tetris/modes/marathon_wcb.lua new file mode 100644 index 0000000..1a31413 --- /dev/null +++ b/tetris/modes/marathon_wcb.lua @@ -0,0 +1,133 @@ +require 'funcs' + +local GameMode = require 'tetris.modes.gamemode' +local Piece = require 'tetris.components.piece' + +local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls' + +local MarathonWCBGame = GameMode:extend() + +MarathonWCBGame.name = "Marathon WCB" +MarathonWCBGame.hash = "MarathonWCB" +MarathonWCBGame.tagline = "When all the pieces slip right to their destinations... can you keep up?" + + +function MarathonWCBGame:new() + MarathonWCBGame.super:new() + + self.pieces = 0 + self.randomizer = History6RollsRandomizer() + + self.lock_drop = true + self.lock_hard_drop = true + self.instant_hard_drop = true + self.instant_soft_drop = true + self.enable_hold = false + self.next_queue_length = 3 + + self.piece_is_active = false +end + +function MarathonWCBGame:getDropSpeed() + return 20 +end + +function MarathonWCBGame:getARR() + return 0 +end + +function MarathonWCBGame:getARE() + return 0 +end + +function MarathonWCBGame:getLineARE() + return 0 +end + +function MarathonWCBGame:getDasLimit() + return 0 +end + +function MarathonWCBGame:getLineClearDelay() + return 0 +end + +function MarathonWCBGame:getLockDelay() + return math.huge +end + +function MarathonWCBGame:getGravity() + return self.piece_is_active and 20 or 0 +end + +function MarathonWCBGame:advanceOneFrame() + if self.clear then + self.roll_frames = self.roll_frames + 1 + if self.roll_frames > 150 then + self.completed = true + end + return false + elseif self.ready_frames == 0 then + self.frames = self.frames + 1 + end + return true +end + +function MarathonWCBGame:onAttemptPieceMove() + if self.piece ~= nil then + -- don't let the piece move before it's finished dropping + self.piece:dropToBottom(self.grid) + end + self.piece_is_active = true +end + +function MarathonWCBGame:onAttemptPieceRotate() + self.piece_is_active = true +end + +function MarathonWCBGame:onPieceLock() + self.piece_is_active = false + self.pieces = self.pieces + 1 +end + +function MarathonWCBGame:onLineClear(cleared_row_count) + if not self.clear then + self.lines = self.lines + cleared_row_count + end +end + +function MarathonWCBGame:drawGrid(ruleset) + self.grid:draw() + if self.piece ~= nil then + self:drawGhostPiece(ruleset) + end +end + +function MarathonWCBGame:getHighscoreData() + return { + pieces = self.pieces, + frames = self.frames, + } +end + +function MarathonWCBGame:drawScoringInfo() + MarathonWCBGame.super.drawScoringInfo(self) + love.graphics.setColor(1, 1, 1, 1) + + local text_x = config["side_next"] and 320 or 240 + + love.graphics.setFont(font_3x5_2) + love.graphics.printf("NEXT", 64, 40, 40, "left") + love.graphics.printf("lines", text_x, 160, 80, "left") + love.graphics.printf("pieces", text_x, 220, 80, "left") + + love.graphics.setFont(font_3x5_3) + love.graphics.printf(self.lines, text_x, 180, 80, "left") + love.graphics.printf(self.pieces, text_x, 240, 80, "left") +end + +function MarathonWCBGame:getBackground() + return (math.floor(self.pieces / 50) % 20) +end + +return MarathonWCBGame diff --git a/tetris/modes/race_40.lua b/tetris/modes/race_40.lua index 9f1a312..b0c608a 100644 --- a/tetris/modes/race_40.lua +++ b/tetris/modes/race_40.lua @@ -25,7 +25,7 @@ function Race40Game:new() self.lock_drop = true self.lock_hard_drop = true self.instant_hard_drop = true - self.instant_soft_drop = false + self.instant_soft_drop = true self.enable_hold = true self.next_queue_length = 3 end @@ -39,11 +39,11 @@ function Race40Game:getARR() end function Race40Game:getARE() - return 0 + return 4 end function Race40Game:getLineARE() - return self:getARE() + return 2 end function Race40Game:getDasLimit() @@ -51,15 +51,15 @@ function Race40Game:getDasLimit() end function Race40Game:getLineClearDelay() - return 0 + return 2 end function Race40Game:getLockDelay() - return 15 + return 30 end function Race40Game:getGravity() - return 1/64 + return 20 end function Race40Game:advanceOneFrame()