mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 09:59:03 -06:00
Compare commits
3 Commits
9b41e56135
...
ca85107063
Author | SHA1 | Date | |
---|---|---|---|
|
ca85107063 | ||
|
fdcec19d56 | ||
|
89c7205347 |
@ -1 +1 @@
|
|||||||
version = "v0.3"
|
version = "v0.3.1"
|
@ -6,13 +6,15 @@ ReplayScene.title = "Replay"
|
|||||||
|
|
||||||
function ReplayScene:new(replay, game_mode, ruleset, inputs)
|
function ReplayScene:new(replay, game_mode, ruleset, inputs)
|
||||||
config.gamesettings = replay["gamesettings"]
|
config.gamesettings = replay["gamesettings"]
|
||||||
|
love.math.setRandomSeed(replay["random_low"], replay["random_high"])
|
||||||
|
love.math.setRandomState(replay["random_state"])
|
||||||
|
self.retry_replay = replay
|
||||||
|
self.retry_mode = game_mode
|
||||||
|
self.retry_ruleset = ruleset
|
||||||
self.secret_inputs = inputs
|
self.secret_inputs = inputs
|
||||||
self.game = game_mode(self.secret_inputs)
|
self.game = game_mode(self.secret_inputs)
|
||||||
self.ruleset = ruleset(self.game)
|
self.ruleset = ruleset(self.game)
|
||||||
-- Replace piece randomizer with replay piece sequence
|
self.game:initialize(self.ruleset, true)
|
||||||
local randomizer = Sequence()
|
|
||||||
randomizer.sequence = replay["pieces"]
|
|
||||||
self.game:initializeReplay(self.ruleset, randomizer)
|
|
||||||
self.inputs = {
|
self.inputs = {
|
||||||
left=false,
|
left=false,
|
||||||
right=false,
|
right=false,
|
||||||
@ -26,7 +28,7 @@ function ReplayScene:new(replay, game_mode, ruleset, inputs)
|
|||||||
hold=false,
|
hold=false,
|
||||||
}
|
}
|
||||||
self.paused = false
|
self.paused = false
|
||||||
self.replay = replay
|
self.replay = deepcopy(replay)
|
||||||
self.replay_index = 1
|
self.replay_index = 1
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "Viewing a replay",
|
details = "Viewing a replay",
|
||||||
@ -56,15 +58,27 @@ end
|
|||||||
|
|
||||||
function ReplayScene:render()
|
function ReplayScene:render()
|
||||||
self.game:draw(self.paused)
|
self.game:draw(self.paused)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf("REPLAY", 0, 0, 635, "right")
|
love.graphics.printf("REPLAY", 0, 0, 635, "right")
|
||||||
end
|
end
|
||||||
|
|
||||||
function ReplayScene:onInputPress(e)
|
function ReplayScene:onInputPress(e)
|
||||||
if (e.input == "menu_back") then
|
if (
|
||||||
|
e.input == "menu_back" or
|
||||||
|
e.input == "menu_decide" or
|
||||||
|
e.input == "retry"
|
||||||
|
) then
|
||||||
self.game:onExit()
|
self.game:onExit()
|
||||||
loadSave()
|
loadSave()
|
||||||
scene = ReplaySelectScene()
|
love.math.setRandomSeed(os.time())
|
||||||
|
scene = (
|
||||||
|
(e.input == "retry") and
|
||||||
|
ReplayScene(
|
||||||
|
self.retry_replay, self.retry_mode,
|
||||||
|
self.retry_ruleset, self.secret_inputs
|
||||||
|
) or ReplaySelectScene()
|
||||||
|
)
|
||||||
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()
|
||||||
|
@ -90,7 +90,10 @@ function ReplaySelectScene:render()
|
|||||||
)
|
)
|
||||||
|
|
||||||
-- Same graphic as mode select
|
-- Same graphic as mode select
|
||||||
love.graphics.draw(misc_graphics["select_mode"], 20, 40)
|
--love.graphics.draw(misc_graphics["select_mode"], 20, 40)
|
||||||
|
|
||||||
|
love.graphics.setFont(font_3x5_4)
|
||||||
|
love.graphics.print("SELECT REPLAY", 20, 35)
|
||||||
|
|
||||||
if self.display_warning then
|
if self.display_warning then
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
|
@ -20,7 +20,7 @@ function SettingsScene:new()
|
|||||||
self.menu_state = 1
|
self.menu_state = 1
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "In settings",
|
details = "In settings",
|
||||||
state = settingsidle[math.random(#settingsidle)],
|
state = settingsidle[love.math.random(#settingsidle)],
|
||||||
largeImageKey = "settings",
|
largeImageKey = "settings",
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -44,9 +44,9 @@ function TitleScene:new()
|
|||||||
self.text_flag = false
|
self.text_flag = false
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "In menus",
|
details = "In menus",
|
||||||
state = mainmenuidle[math.random(#mainmenuidle)],
|
state = mainmenuidle[love.math.random(#mainmenuidle)],
|
||||||
largeImageKey = "1year",
|
largeImageKey = "icon2",
|
||||||
largeImageText = version.." | Thanks for 1 year!"
|
largeImageText = version
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,24 +63,19 @@ end
|
|||||||
function TitleScene:render()
|
function TitleScene:render()
|
||||||
love.graphics.setFont(font_3x5_4)
|
love.graphics.setFont(font_3x5_4)
|
||||||
love.graphics.setColor(1, 1, 1, 1 - self.snow_bg_opacity)
|
love.graphics.setColor(1, 1, 1, 1 - self.snow_bg_opacity)
|
||||||
|
love.graphics.draw(
|
||||||
|
backgrounds["title"], -- title_night
|
||||||
|
0, 0, 0,
|
||||||
|
0.5, 0.5
|
||||||
|
)
|
||||||
--[[
|
--[[
|
||||||
love.graphics.draw(
|
|
||||||
backgrounds["title"],
|
|
||||||
0, 0, 0,
|
|
||||||
0.5, 0.5
|
|
||||||
)
|
|
||||||
]]
|
|
||||||
love.graphics.draw(
|
|
||||||
backgrounds["title_night"],
|
|
||||||
0, 0, 0,
|
|
||||||
0.5, 0.5
|
|
||||||
)
|
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
misc_graphics["icon"],
|
misc_graphics["icon"],
|
||||||
460, 170, 0,
|
460, 170, 0,
|
||||||
2, 2
|
2, 2
|
||||||
)
|
)
|
||||||
love.graphics.printf("Thanks for 1 year!", 430, 280, 160, "center")
|
]]
|
||||||
|
--love.graphics.printf("Thanks for 1 year!", 430, 280, 160, "center")
|
||||||
|
|
||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setFont(font_3x5_2)
|
||||||
love.graphics.setColor(1, 1, 1, self.snow_bg_opacity)
|
love.graphics.setColor(1, 1, 1, self.snow_bg_opacity)
|
||||||
@ -126,8 +121,6 @@ function TitleScene:onInputPress(e)
|
|||||||
playSE("cursor")
|
playSE("cursor")
|
||||||
elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
|
elseif e.input == "menu_back" or e.scancode == "backspace" or e.scancode == "delete" then
|
||||||
love.event.quit()
|
love.event.quit()
|
||||||
-- no winter easter egg for now
|
|
||||||
--[[
|
|
||||||
else
|
else
|
||||||
self.text = self.text .. (e.scancode or "")
|
self.text = self.text .. (e.scancode or "")
|
||||||
if self.text == "ffffff" then
|
if self.text == "ffffff" then
|
||||||
@ -136,7 +129,6 @@ function TitleScene:onInputPress(e)
|
|||||||
largeImageKey = "snow"
|
largeImageKey = "snow"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
]]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,6 +17,12 @@ GameMode.tagline = ""
|
|||||||
GameMode.rollOpacityFunction = function(age) return 0 end
|
GameMode.rollOpacityFunction = function(age) return 0 end
|
||||||
|
|
||||||
function GameMode:new(secret_inputs)
|
function GameMode:new(secret_inputs)
|
||||||
|
self.replay_inputs = {}
|
||||||
|
self.random_low, self.random_high = love.math.getRandomSeed()
|
||||||
|
self.random_state = love.math.getRandomState()
|
||||||
|
self.secret_inputs = secret_inputs
|
||||||
|
self.save_replay = true
|
||||||
|
|
||||||
self.grid = Grid(10, 24)
|
self.grid = Grid(10, 24)
|
||||||
self.randomizer = Randomizer()
|
self.randomizer = Randomizer()
|
||||||
self.piece = nil
|
self.piece = nil
|
||||||
@ -73,10 +79,6 @@ function GameMode:new(secret_inputs)
|
|||||||
self.section_start_time = 0
|
self.section_start_time = 0
|
||||||
self.section_times = { [0] = 0 }
|
self.section_times = { [0] = 0 }
|
||||||
self.secondary_section_times = { [0] = 0 }
|
self.secondary_section_times = { [0] = 0 }
|
||||||
self.replay_inputs = {}
|
|
||||||
self.secret_inputs = secret_inputs
|
|
||||||
self.replay_pieces = {}
|
|
||||||
self.save_replay = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:getARR() return 1 end
|
function GameMode:getARR() return 1 end
|
||||||
@ -91,9 +93,6 @@ function GameMode:getGravity() return 1/64 end
|
|||||||
|
|
||||||
function GameMode:getNextPiece(ruleset)
|
function GameMode:getNextPiece(ruleset)
|
||||||
local shape = self.used_randomizer:nextPiece()
|
local shape = self.used_randomizer:nextPiece()
|
||||||
if self.save_replay then
|
|
||||||
self.replay_pieces[#self.replay_pieces + 1] = shape
|
|
||||||
end
|
|
||||||
return {
|
return {
|
||||||
skin = self:getSkin(),
|
skin = self:getSkin(),
|
||||||
shape = shape,
|
shape = shape,
|
||||||
@ -105,16 +104,7 @@ function GameMode:getSkin()
|
|||||||
return "2tie"
|
return "2tie"
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:sharedInitialize(ruleset)
|
function GameMode:initialize(ruleset, replay)
|
||||||
self.ruleset = ruleset
|
|
||||||
for i = 1, math.max(self.next_queue_length, 1) do
|
|
||||||
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
|
||||||
end
|
|
||||||
self.lock_on_soft_drop = ({ruleset.softdrop_lock, self.instant_soft_drop, false, true})[config.gamesettings.manlock]
|
|
||||||
self.lock_on_hard_drop = ({ruleset.harddrop_lock, self.instant_hard_drop, true, false})[config.gamesettings.manlock]
|
|
||||||
end
|
|
||||||
|
|
||||||
function GameMode:initialize(ruleset)
|
|
||||||
-- generate next queue
|
-- generate next queue
|
||||||
self.used_randomizer = (
|
self.used_randomizer = (
|
||||||
table.equalvalues(
|
table.equalvalues(
|
||||||
@ -123,20 +113,22 @@ function GameMode:initialize(ruleset)
|
|||||||
) and
|
) and
|
||||||
self.randomizer or BagRandomizer(table.keys(ruleset.colourscheme))
|
self.randomizer or BagRandomizer(table.keys(ruleset.colourscheme))
|
||||||
)
|
)
|
||||||
self:sharedInitialize(ruleset)
|
self.ruleset = ruleset
|
||||||
end
|
self.save_replay = not replay
|
||||||
|
for i = 1, math.max(self.next_queue_length, 1) do
|
||||||
function GameMode:initializeReplay(ruleset, randomizer)
|
table.insert(self.next_queue, self:getNextPiece(ruleset))
|
||||||
self.used_randomizer = randomizer
|
end
|
||||||
self.save_replay = false
|
self.lock_on_soft_drop = ({ruleset.softdrop_lock, self.instant_soft_drop, false, true})[config.gamesettings.manlock]
|
||||||
self:sharedInitialize(ruleset)
|
self.lock_on_hard_drop = ({ruleset.harddrop_lock, self.instant_hard_drop, true, false})[config.gamesettings.manlock]
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:saveReplay()
|
function GameMode:saveReplay()
|
||||||
-- Save replay.
|
-- Save replay.
|
||||||
local replay = {}
|
local replay = {}
|
||||||
replay["inputs"] = self.replay_inputs
|
replay["inputs"] = self.replay_inputs
|
||||||
replay["pieces"] = self.replay_pieces
|
replay["random_low"] = self.random_low
|
||||||
|
replay["random_high"] = self.random_high
|
||||||
|
replay["random_state"] = self.random_state
|
||||||
replay["mode"] = self.name
|
replay["mode"] = self.name
|
||||||
replay["ruleset"] = self.ruleset.name
|
replay["ruleset"] = self.ruleset.name
|
||||||
replay["timer"] = self.frames
|
replay["timer"] = self.frames
|
||||||
|
@ -13,7 +13,7 @@ function BagRandomizer:generatePiece()
|
|||||||
table.insert(self.bag, v)
|
table.insert(self.bag, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local x = math.random(table.getn(self.bag))
|
local x = love.math.random(table.getn(self.bag))
|
||||||
return table.remove(self.bag, x)
|
return table.remove(self.bag, x)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ function Bag7Randomizer:generatePiece()
|
|||||||
if next(self.bag) == nil then
|
if next(self.bag) == nil then
|
||||||
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
end
|
end
|
||||||
local x = math.random(table.getn(self.bag))
|
local x = love.math.random(table.getn(self.bag))
|
||||||
return table.remove(self.bag, x)
|
return table.remove(self.bag, x)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ function Bag7NoSZOStartRandomizer:shuffleBag()
|
|||||||
local b = self.bag
|
local b = self.bag
|
||||||
local ln = #b
|
local ln = #b
|
||||||
for i = 1, ln do
|
for i = 1, ln do
|
||||||
local j = math.random(i, ln)
|
local j = love.math.random(i, ln)
|
||||||
b[i], b[j] = b[j], b[i]
|
b[i], b[j] = b[j], b[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,11 +10,11 @@ end
|
|||||||
function History4RollsRandomizer:generatePiece()
|
function History4RollsRandomizer:generatePiece()
|
||||||
if self.first then
|
if self.first then
|
||||||
self.first = false
|
self.first = false
|
||||||
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
|
||||||
else
|
else
|
||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
local x = math.random(7)
|
local x = love.math.random(7)
|
||||||
if not inHistory(shapes[x], self.history) or i == 4 then
|
if not inHistory(shapes[x], self.history) or i == 4 then
|
||||||
return self:updateHistory(shapes[x])
|
return self:updateHistory(shapes[x])
|
||||||
end
|
end
|
||||||
|
@ -10,11 +10,11 @@ end
|
|||||||
function History6RollsRandomizer:generatePiece()
|
function History6RollsRandomizer:generatePiece()
|
||||||
if self.first then
|
if self.first then
|
||||||
self.first = false
|
self.first = false
|
||||||
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
|
||||||
else
|
else
|
||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
local x = math.random(7)
|
local x = love.math.random(7)
|
||||||
if not inHistory(shapes[x], self.history) or i == 6 then
|
if not inHistory(shapes[x], self.history) or i == 6 then
|
||||||
return self:updateHistory(shapes[x])
|
return self:updateHistory(shapes[x])
|
||||||
end
|
end
|
||||||
|
@ -28,12 +28,12 @@ end
|
|||||||
function History6Rolls35PoolRandomizer:generatePiece()
|
function History6Rolls35PoolRandomizer:generatePiece()
|
||||||
local index, x
|
local index, x
|
||||||
if self.first then
|
if self.first then
|
||||||
index = math.random(20)
|
index = love.math.random(20)
|
||||||
x = self.pool[index]
|
x = self.pool[index]
|
||||||
self.first = false
|
self.first = false
|
||||||
else
|
else
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
index = math.random(#self.pool)
|
index = love.math.random(#self.pool)
|
||||||
x = self.pool[index]
|
x = self.pool[index]
|
||||||
if not inHistory(x, self.history) or i == 6 then
|
if not inHistory(x, self.history) or i == 6 then
|
||||||
break
|
break
|
||||||
|
@ -16,7 +16,7 @@ function Randomizer:initialize()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Randomizer:generatePiece()
|
function Randomizer:generatePiece()
|
||||||
return self.possible_pieces[math.random(7)]
|
return self.possible_pieces[love.math.random(7)]
|
||||||
end
|
end
|
||||||
|
|
||||||
return Randomizer
|
return Randomizer
|
||||||
|
Loading…
Reference in New Issue
Block a user