From 0d13a9f236bc753849924f08bc0c2de08f409b06 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Tue, 5 Jan 2021 21:59:50 -0500 Subject: [PATCH] Can send inputs from mode select to game Warning: this may break some things --- scene/game.lua | 11 ++++++----- scene/mode_select.lua | 18 +++++++++++++++++- tetris/modes/gamemode.lua | 6 +++--- tetris/modes/sakura.lua | 12 ++++++++++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/scene/game.lua b/scene/game.lua index 17ad588..bc74698 100644 --- a/scene/game.lua +++ b/scene/game.lua @@ -4,12 +4,13 @@ GameScene.title = "Game" require 'load.save' -function GameScene:new(game_mode, ruleset) +function GameScene:new(game_mode, ruleset, inputs) self.retry_mode = game_mode self.retry_ruleset = ruleset - self.game = game_mode() + self.secret_inputs = copy(inputs) + self.game = game_mode(self.secret_inputs) self.ruleset = ruleset() - self.game:initialize(self.ruleset) + self.game:initialize(self.ruleset, self.secret_inputs) self.inputs = { left=false, right=false, @@ -82,9 +83,9 @@ function GameScene:onInputPress(e) highscore_entry = self.game:getHighscoreData() highscore_hash = self.game.hash .. "-" .. self.ruleset.hash submitHighscore(highscore_hash, highscore_entry) - scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset) or ModeSelectScene() + scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs) or ModeSelectScene() elseif e.input == "retry" then - scene = GameScene(self.retry_mode, self.retry_ruleset) + scene = GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs) elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then self.paused = not self.paused if self.paused then pauseBGM() diff --git a/scene/mode_select.lua b/scene/mode_select.lua index 31e9f7b..b1594d8 100755 --- a/scene/mode_select.lua +++ b/scene/mode_select.lua @@ -11,6 +11,14 @@ function ModeSelectScene:new() ruleset = current_ruleset, select = "mode", } + self.secret_inputs = { + rotate_left = false, + rotate_left2 = false, + rotate_right = false, + rotate_right2 = false, + rotate_180 = false, + hold = false, + } DiscordRPC:update({ details = "In menus", state = "Choosing a mode", @@ -67,7 +75,7 @@ function ModeSelectScene:onInputPress(e) config.current_ruleset = current_ruleset playSE("mode_decide") saveConfig() - scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset]) + scene = GameScene(game_modes[self.menu_state.mode], rulesets[self.menu_state.ruleset], self.secret_inputs) elseif e.input == "up" or e.scancode == "up" then self:changeOption(-1) playSE("cursor") @@ -79,6 +87,14 @@ function ModeSelectScene:onInputPress(e) playSE("cursor_lr") elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then scene = TitleScene() + else + self.secret_inputs[e.input] = true + end +end + +function ModeSelectScene:onInputRelease(e) + if e.input == "hold" or (e.input and string.sub(e.input, 1, 7) == "rotate_") then + self.secret_inputs[e.input] = false end end diff --git a/tetris/modes/gamemode.lua b/tetris/modes/gamemode.lua index 80ab0e1..8eeeb53 100644 --- a/tetris/modes/gamemode.lua +++ b/tetris/modes/gamemode.lua @@ -11,7 +11,7 @@ local GameMode = Object:extend() GameMode.rollOpacityFunction = function(age) return 0 end -function GameMode:new() +function GameMode:new(secret_inputs) self.grid = Grid() self.randomizer = Randomizer() self.piece = nil @@ -80,9 +80,9 @@ function GameMode:getNextPiece(ruleset) } end -function GameMode:initialize(ruleset) +function GameMode:initialize(ruleset, secret_inputs) -- generate next queue - self:new() + self:new(secret_inputs) for i = 1, self.next_queue_length do table.insert(self.next_queue, self:getNextPiece(ruleset)) end diff --git a/tetris/modes/sakura.lua b/tetris/modes/sakura.lua index ec5cd04..8b32870 100644 --- a/tetris/modes/sakura.lua +++ b/tetris/modes/sakura.lua @@ -4,6 +4,7 @@ local GameMode = require 'tetris.modes.gamemode' local Piece = require 'tetris.components.piece' local SakuraRandomizer = require 'tetris.randomizers.sakura' +local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls_35bag' local SakuraGame = GameMode:extend() @@ -264,10 +265,14 @@ local maps = { local STAGE_TRANSITION_TIME = 300 -function SakuraGame:new() +function SakuraGame:new(secret_inputs) self.super:new() - self.randomizer = SakuraRandomizer() + self.randomizer = ( + ( + secret_inputs.rotate_left and secret_inputs.rotate_right + ) and History6RollsRandomizer() or SakuraRandomizer() + ) self.current_map = 1 self.time_limit = 10800 @@ -482,6 +487,9 @@ function SakuraGame:drawScoringInfo() if effects[self.current_map] then love.graphics.printf("EFFECT: " .. effects[self.current_map], 240, 300, 160, "left") end + if self.randomizer.history then + love.graphics.printf("RANDOM PIECES ACTIVE!", 240, 295, 200, "left") + end love.graphics.setFont(font_3x5_3) love.graphics.setColor(