mirror of
https://github.com/SashLilac/cambridge.git
synced 2025-05-13 20:21:25 -05:00
Compare commits
12 Commits
v0.3.3.2
...
7199aa7ef6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7199aa7ef6 | ||
|
|
a972c31d9a | ||
|
|
02f314997d | ||
|
|
4769daedf4 | ||
|
|
52d4aeb3d0 | ||
|
|
91279c9f38 | ||
|
|
0572803627 | ||
|
|
1fef7b4880 | ||
|
|
e09b044de4 | ||
|
|
7d6f783c40 | ||
|
|
9d365f61a7 | ||
|
|
082697c3cd |
21
load/bgm.lua
21
load/bgm.lua
@@ -7,13 +7,15 @@ bgm = {
|
||||
|
||||
local current_bgm = nil
|
||||
local bgm_locked = false
|
||||
local unfocused = false
|
||||
|
||||
function switchBGM(sound, subsound)
|
||||
if bgm_locked then
|
||||
return
|
||||
end
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:stop()
|
||||
end
|
||||
if bgm_locked or config.bgm_volume <= 0 then
|
||||
if config.bgm_volume <= 0 then
|
||||
current_bgm = nil
|
||||
elseif sound ~= nil then
|
||||
if subsound ~= nil then
|
||||
@@ -67,24 +69,19 @@ function processBGMFadeout(dt)
|
||||
fadeout_time = 0
|
||||
fading_bgm = false
|
||||
end
|
||||
current_bgm:setVolume(fadeout_time * config.bgm_volume / total_fadeout_time)
|
||||
current_bgm:setVolume(
|
||||
fadeout_time * config.bgm_volume / total_fadeout_time
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function pauseBGM(f)
|
||||
if f then
|
||||
unfocused = true
|
||||
end
|
||||
function pauseBGM()
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:pause()
|
||||
end
|
||||
end
|
||||
|
||||
function resumeBGM(f)
|
||||
if f and scene.paused and unfocused then
|
||||
unfocused = false
|
||||
return
|
||||
end
|
||||
function resumeBGM()
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:play()
|
||||
end
|
||||
|
||||
10
main.lua
10
main.lua
@@ -114,7 +114,7 @@ function love.keypressed(key, scancode)
|
||||
scene.restart_message = true
|
||||
if config.secret then playSE("mode_decide")
|
||||
else playSE("erase") end
|
||||
-- f12 is reserved for saving screenshots
|
||||
-- f12 is reserved for saving screenshots
|
||||
elseif scancode == "f12" then
|
||||
local ss_name = os.date("ss/%Y-%m-%d_%H-%M-%S.png")
|
||||
local info = love.filesystem.getInfo("ss", "directory")
|
||||
@@ -280,14 +280,6 @@ function love.wheelmoved(x, y)
|
||||
scene:onInputPress({input=nil, type="wheel", x=x, y=y})
|
||||
end
|
||||
|
||||
function love.focus(f)
|
||||
if f then
|
||||
resumeBGM(true)
|
||||
else
|
||||
pauseBGM(true)
|
||||
end
|
||||
end
|
||||
|
||||
function love.resize(w, h)
|
||||
GLOBAL_CANVAS:release()
|
||||
GLOBAL_CANVAS = love.graphics.newCanvas(w, h)
|
||||
|
||||
@@ -16,9 +16,7 @@ function CreditsScene:new()
|
||||
end
|
||||
|
||||
function CreditsScene:update()
|
||||
if love.window.hasFocus() then
|
||||
self.frames = self.frames + 1
|
||||
end
|
||||
self.frames = self.frames + 1
|
||||
if self.frames >= 2100 * self.scroll_speed then
|
||||
playSE("mode_decide")
|
||||
scene = TitleScene()
|
||||
|
||||
@@ -36,6 +36,8 @@ function ReplayScene:new(replay, game_mode, ruleset)
|
||||
self.game.pause_time = replay["pause_time"]
|
||||
self.replay = deepcopy(replay)
|
||||
self.replay_index = 1
|
||||
self.replay_speed = 1
|
||||
self.show_invisible = false
|
||||
DiscordRPC:update({
|
||||
details = "Viewing a replay",
|
||||
state = self.game.name,
|
||||
@@ -44,18 +46,22 @@ function ReplayScene:new(replay, game_mode, ruleset)
|
||||
end
|
||||
|
||||
function ReplayScene:update()
|
||||
local frames_left = self.replay_speed
|
||||
if not self.paused then
|
||||
self.inputs = self.replay["inputs"][self.replay_index]["inputs"]
|
||||
self.replay["inputs"][self.replay_index]["frames"] = self.replay["inputs"][self.replay_index]["frames"] - 1
|
||||
if self.replay["inputs"][self.replay_index]["frames"] == 0 and self.replay_index < table.getn(self.replay["inputs"]) then
|
||||
self.replay_index = self.replay_index + 1
|
||||
while frames_left > 0 do
|
||||
frames_left = frames_left - 1
|
||||
self.inputs = self.replay["inputs"][self.replay_index]["inputs"]
|
||||
self.replay["inputs"][self.replay_index]["frames"] = self.replay["inputs"][self.replay_index]["frames"] - 1
|
||||
if self.replay["inputs"][self.replay_index]["frames"] == 0 and self.replay_index < table.getn(self.replay["inputs"]) then
|
||||
self.replay_index = self.replay_index + 1
|
||||
end
|
||||
local input_copy = {}
|
||||
for input, value in pairs(self.inputs) do
|
||||
input_copy[input] = value
|
||||
end
|
||||
self.game:update(input_copy, self.ruleset)
|
||||
self.game.grid:update()
|
||||
end
|
||||
local input_copy = {}
|
||||
for input, value in pairs(self.inputs) do
|
||||
input_copy[input] = value
|
||||
end
|
||||
self.game:update(input_copy, self.ruleset)
|
||||
self.game.grid:update()
|
||||
DiscordRPC:update({
|
||||
details = "Viewing a replay",
|
||||
state = self.game.name,
|
||||
@@ -69,6 +75,11 @@ function ReplayScene:render()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf("REPLAY", 0, 0, 635, "right")
|
||||
local pauses_y_coordinate = 23
|
||||
if self.replay_speed > 1 then
|
||||
pauses_y_coordinate = pauses_y_coordinate + 20
|
||||
love.graphics.printf(self.replay_speed.."X", 0, 20, 635, "right")
|
||||
end
|
||||
love.graphics.setFont(font_3x5_2)
|
||||
if self.game.pause_time and self.game.pause_count then
|
||||
if self.game.pause_time > 0 or self.game.pause_count > 0 then
|
||||
@@ -77,10 +88,16 @@ function ReplayScene:render()
|
||||
self.game.pause_count,
|
||||
self.game.pause_count == 1 and "" or "S",
|
||||
formatTime(self.game.pause_time)
|
||||
), 0, 23, 635, "right")
|
||||
), 0, pauses_y_coordinate, 635, "right")
|
||||
end
|
||||
else
|
||||
love.graphics.printf("?? PAUSES (--:--.--)", 0, 23, 635, "right")
|
||||
love.graphics.printf("?? PAUSES (--:--.--)", 0, pauses_y_coordinate, 635, "right")
|
||||
end
|
||||
if self.show_invisible then
|
||||
self.game.grid:draw()
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.setFont(font_3x5_3)
|
||||
love.graphics.printf("SHOW INVIS", 64, 60, 160, "center")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,6 +121,18 @@ function ReplayScene:onInputPress(e)
|
||||
self.paused = not self.paused
|
||||
if self.paused then pauseBGM()
|
||||
else resumeBGM() end
|
||||
elseif e.input == "left" then
|
||||
self.replay_speed = self.replay_speed - 1
|
||||
if self.replay_speed < 1 then
|
||||
self.replay_speed = 1
|
||||
end
|
||||
elseif e.input == "right" then
|
||||
self.replay_speed = self.replay_speed + 1
|
||||
if self.replay_speed > 99 then
|
||||
self.replay_speed = 99
|
||||
end
|
||||
elseif e.input == "hold" then
|
||||
self.show_invisible = not self.show_invisible
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ function Marathon2020Game:sectionPassed(old_level, new_level)
|
||||
)
|
||||
else
|
||||
return (
|
||||
(new_level < 2001 and math.floor(old_level / 100) < math.floor(new_level / 100)) or
|
||||
(new_level < 2000 and math.floor(old_level / 100) < math.floor(new_level / 100)) or
|
||||
(new_level >= 2020)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ end
|
||||
function Survival2020Game:onPieceEnter()
|
||||
if not self.clear and (
|
||||
(self.level < 1900 and self.level % 100 ~= 99) or
|
||||
self.level == 2019
|
||||
(1900 <= self.level and self.level < 2019)
|
||||
) then
|
||||
self.level = self.level + 1
|
||||
end
|
||||
@@ -249,7 +249,7 @@ function Survival2020Game:drawScoringInfo()
|
||||
end
|
||||
|
||||
function Survival2020Game:getBackground()
|
||||
return math.floor(self.level / 100)
|
||||
return math.min(19, math.floor(self.level / 100))
|
||||
end
|
||||
|
||||
function Survival2020Game:getHighscoreData()
|
||||
|
||||
Reference in New Issue
Block a user