Replay system v2
This commit is contained in:
@@ -39,14 +39,24 @@ end
|
||||
function ModeSelectScene:update()
|
||||
switchBGM(nil) -- experimental
|
||||
|
||||
if self.das_up or self.das_down then
|
||||
if self.das_up or self.das_down or self.das_left or self.das_right then
|
||||
self.das = self.das + 1
|
||||
else
|
||||
self.das = 0
|
||||
end
|
||||
|
||||
if self.das >= 15 then
|
||||
self:changeOption(self.das_up and -1 or 1)
|
||||
local change = 0
|
||||
if self.das_up then
|
||||
change = -1
|
||||
elseif self.das_down then
|
||||
change = 1
|
||||
elseif self.das_left then
|
||||
change = -9
|
||||
elseif self.das_right then
|
||||
change = 9
|
||||
end
|
||||
self:changeOption(change)
|
||||
self.das = self.das - 4
|
||||
end
|
||||
|
||||
@@ -136,10 +146,26 @@ function ModeSelectScene:onInputPress(e)
|
||||
self:changeOption(-1)
|
||||
self.das_up = true
|
||||
self.das_down = nil
|
||||
self.das_left = nil
|
||||
self.das_right = nil
|
||||
elseif e.input == "down" or e.scancode == "down" then
|
||||
self:changeOption(1)
|
||||
self.das_down = true
|
||||
self.das_up = nil
|
||||
self.das_left = nil
|
||||
self.das_right = nil
|
||||
elseif e.input == "left" or e.scancode == "left" then
|
||||
self:changeOption(-9)
|
||||
self.das_left = true
|
||||
self.das_right = nil
|
||||
self.das_up = nil
|
||||
self.das_down = nil
|
||||
elseif e.input == "right" or e.scancode == "right" then
|
||||
self:changeOption(9)
|
||||
self.das_right = true
|
||||
self.das_left = nil
|
||||
self.das_up = nil
|
||||
self.das_down = nil
|
||||
elseif e.input == "left" or e.input == "right" or e.scancode == "left" or e.scancode == "right" then
|
||||
self:switchSelect()
|
||||
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||
@@ -154,6 +180,10 @@ function ModeSelectScene:onInputRelease(e)
|
||||
self.das_up = nil
|
||||
elseif e.input == "down" or e.scancode == "down" then
|
||||
self.das_down = nil
|
||||
elseif e.input == "right" or e.scancode == "right" then
|
||||
self.das_right = nil
|
||||
elseif e.input == "left" or e.scancode == "left" then
|
||||
self.das_left = nil
|
||||
elseif e.input then
|
||||
self.secret_inputs[e.input] = false
|
||||
end
|
||||
|
||||
@@ -5,11 +5,12 @@ local ReplayScene = Scene:extend()
|
||||
ReplayScene.title = "Replay"
|
||||
|
||||
function ReplayScene:new(replay, game_mode, ruleset, inputs)
|
||||
config.gamesettings = replay["gamesettings"]
|
||||
self.secret_inputs = inputs
|
||||
self.game = game_mode(self.secret_inputs)
|
||||
self.ruleset = ruleset(self.game)
|
||||
-- Replace piece randomizer with replay piece sequence
|
||||
local randomizer = Sequence(table.keys(ruleset.colourscheme))
|
||||
local randomizer = Sequence()
|
||||
randomizer.sequence = replay["pieces"]
|
||||
self.game:initializeReplay(self.ruleset, randomizer)
|
||||
self.inputs = {
|
||||
@@ -28,7 +29,7 @@ function ReplayScene:new(replay, game_mode, ruleset, inputs)
|
||||
self.replay = replay
|
||||
self.replay_index = 1
|
||||
DiscordRPC:update({
|
||||
details = self.game.rpc_details,
|
||||
details = "Viewing a replay",
|
||||
state = self.game.name,
|
||||
largeImageKey = "ingame-"..self.game:getBackground().."00"
|
||||
})
|
||||
@@ -55,11 +56,14 @@ end
|
||||
|
||||
function ReplayScene:render()
|
||||
self.game:draw(self.paused)
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf("REPLAY", 0, 0, 635, "right")
|
||||
end
|
||||
|
||||
function ReplayScene:onInputPress(e)
|
||||
if (e.input == "menu_back") then
|
||||
self.game:onExit()
|
||||
loadSave()
|
||||
scene = ReplaySelectScene()
|
||||
elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then
|
||||
self.paused = not self.paused
|
||||
|
||||
@@ -45,7 +45,6 @@ function ReplaySelectScene:new()
|
||||
self.menu_state = {
|
||||
replay = current_replay,
|
||||
}
|
||||
self.secret_inputs = {}
|
||||
self.das = 0
|
||||
DiscordRPC:update({
|
||||
details = "In menus",
|
||||
@@ -55,8 +54,6 @@ function ReplaySelectScene:new()
|
||||
end
|
||||
|
||||
function ReplaySelectScene:update()
|
||||
switchBGM(nil) -- experimental
|
||||
|
||||
if self.das_up or self.das_down or self.das_left or self.das_right then
|
||||
self.das = self.das + 1
|
||||
else
|
||||
@@ -126,6 +123,7 @@ function ReplaySelectScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 0.5)
|
||||
love.graphics.rectangle("fill", 3, 258, 634, 22)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
for idx, replay in ipairs(replays) do
|
||||
if(idx >= self.menu_state.replay-9 and idx <= self.menu_state.replay+9) then
|
||||
@@ -145,9 +143,6 @@ function ReplaySelectScene:onInputPress(e)
|
||||
if (self.display_warning or self.display_error) and e.input then
|
||||
scene = TitleScene()
|
||||
elseif e.type == "wheel" then
|
||||
if e.x % 2 == 1 then
|
||||
self:switchSelect()
|
||||
end
|
||||
if e.y ~= 0 then
|
||||
self:changeOption(-e.y)
|
||||
end
|
||||
@@ -179,7 +174,7 @@ function ReplaySelectScene:onInputPress(e)
|
||||
replays[self.menu_state.replay],
|
||||
mode,
|
||||
rules,
|
||||
self.secret_inputs
|
||||
replays[self.menu_state.replay]["secret_inputs"]
|
||||
)
|
||||
elseif e.input == "up" or e.scancode == "up" then
|
||||
self:changeOption(-1)
|
||||
@@ -207,8 +202,6 @@ function ReplaySelectScene:onInputPress(e)
|
||||
self.das_down = nil
|
||||
elseif e.input == "menu_back" or e.scancode == "delete" or e.scancode == "backspace" then
|
||||
scene = TitleScene()
|
||||
elseif e.input then
|
||||
self.secret_inputs[e.input] = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -221,8 +214,6 @@ function ReplaySelectScene:onInputRelease(e)
|
||||
self.das_right = nil
|
||||
elseif e.input == "left" or e.scancode == "left" then
|
||||
self.das_left = nil
|
||||
elseif e.input then
|
||||
self.secret_inputs[e.input] = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user