mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 14:59:03 -06:00
Can send inputs from mode select to game
Warning: this may break some things
This commit is contained in:
parent
45120bc9f7
commit
0d13a9f236
@ -4,12 +4,13 @@ GameScene.title = "Game"
|
|||||||
|
|
||||||
require 'load.save'
|
require 'load.save'
|
||||||
|
|
||||||
function GameScene:new(game_mode, ruleset)
|
function GameScene:new(game_mode, ruleset, inputs)
|
||||||
self.retry_mode = game_mode
|
self.retry_mode = game_mode
|
||||||
self.retry_ruleset = ruleset
|
self.retry_ruleset = ruleset
|
||||||
self.game = game_mode()
|
self.secret_inputs = copy(inputs)
|
||||||
|
self.game = game_mode(self.secret_inputs)
|
||||||
self.ruleset = ruleset()
|
self.ruleset = ruleset()
|
||||||
self.game:initialize(self.ruleset)
|
self.game:initialize(self.ruleset, self.secret_inputs)
|
||||||
self.inputs = {
|
self.inputs = {
|
||||||
left=false,
|
left=false,
|
||||||
right=false,
|
right=false,
|
||||||
@ -82,9 +83,9 @@ function GameScene:onInputPress(e)
|
|||||||
highscore_entry = self.game:getHighscoreData()
|
highscore_entry = self.game:getHighscoreData()
|
||||||
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
|
||||||
submitHighscore(highscore_hash, highscore_entry)
|
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
|
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
|
elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then
|
||||||
self.paused = not self.paused
|
self.paused = not self.paused
|
||||||
if self.paused then pauseBGM()
|
if self.paused then pauseBGM()
|
||||||
|
@ -11,6 +11,14 @@ function ModeSelectScene:new()
|
|||||||
ruleset = current_ruleset,
|
ruleset = current_ruleset,
|
||||||
select = "mode",
|
select = "mode",
|
||||||
}
|
}
|
||||||
|
self.secret_inputs = {
|
||||||
|
rotate_left = false,
|
||||||
|
rotate_left2 = false,
|
||||||
|
rotate_right = false,
|
||||||
|
rotate_right2 = false,
|
||||||
|
rotate_180 = false,
|
||||||
|
hold = false,
|
||||||
|
}
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "In menus",
|
details = "In menus",
|
||||||
state = "Choosing a mode",
|
state = "Choosing a mode",
|
||||||
@ -67,7 +75,7 @@ function ModeSelectScene:onInputPress(e)
|
|||||||
config.current_ruleset = current_ruleset
|
config.current_ruleset = current_ruleset
|
||||||
playSE("mode_decide")
|
playSE("mode_decide")
|
||||||
saveConfig()
|
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
|
elseif e.input == "up" or e.scancode == "up" then
|
||||||
self:changeOption(-1)
|
self:changeOption(-1)
|
||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
@ -79,6 +87,14 @@ function ModeSelectScene:onInputPress(e)
|
|||||||
playSE("cursor_lr")
|
playSE("cursor_lr")
|
||||||
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||||
scene = TitleScene()
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ local GameMode = Object:extend()
|
|||||||
|
|
||||||
GameMode.rollOpacityFunction = function(age) return 0 end
|
GameMode.rollOpacityFunction = function(age) return 0 end
|
||||||
|
|
||||||
function GameMode:new()
|
function GameMode:new(secret_inputs)
|
||||||
self.grid = Grid()
|
self.grid = Grid()
|
||||||
self.randomizer = Randomizer()
|
self.randomizer = Randomizer()
|
||||||
self.piece = nil
|
self.piece = nil
|
||||||
@ -80,9 +80,9 @@ function GameMode:getNextPiece(ruleset)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:initialize(ruleset)
|
function GameMode:initialize(ruleset, secret_inputs)
|
||||||
-- generate next queue
|
-- generate next queue
|
||||||
self:new()
|
self:new(secret_inputs)
|
||||||
for i = 1, self.next_queue_length do
|
for i = 1, self.next_queue_length do
|
||||||
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
||||||
end
|
end
|
||||||
|
@ -4,6 +4,7 @@ local GameMode = require 'tetris.modes.gamemode'
|
|||||||
local Piece = require 'tetris.components.piece'
|
local Piece = require 'tetris.components.piece'
|
||||||
|
|
||||||
local SakuraRandomizer = require 'tetris.randomizers.sakura'
|
local SakuraRandomizer = require 'tetris.randomizers.sakura'
|
||||||
|
local History6RollsRandomizer = require 'tetris.randomizers.history_6rolls_35bag'
|
||||||
|
|
||||||
local SakuraGame = GameMode:extend()
|
local SakuraGame = GameMode:extend()
|
||||||
|
|
||||||
@ -264,10 +265,14 @@ local maps = {
|
|||||||
|
|
||||||
local STAGE_TRANSITION_TIME = 300
|
local STAGE_TRANSITION_TIME = 300
|
||||||
|
|
||||||
function SakuraGame:new()
|
function SakuraGame:new(secret_inputs)
|
||||||
self.super:new()
|
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.current_map = 1
|
||||||
self.time_limit = 10800
|
self.time_limit = 10800
|
||||||
@ -482,6 +487,9 @@ function SakuraGame:drawScoringInfo()
|
|||||||
if effects[self.current_map] then
|
if effects[self.current_map] then
|
||||||
love.graphics.printf("EFFECT: " .. effects[self.current_map], 240, 300, 160, "left")
|
love.graphics.printf("EFFECT: " .. effects[self.current_map], 240, 300, 160, "left")
|
||||||
end
|
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.setFont(font_3x5_3)
|
||||||
love.graphics.setColor(
|
love.graphics.setColor(
|
||||||
|
Loading…
Reference in New Issue
Block a user