mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 14:39:02 -06:00
A few minor changes, read below
Clean up big pieces for a temporary hotfix, an overhaul soon to come Refactored BGM and SE playing Moved draw code completely into gamemode - mod makers can now control everything on screen
This commit is contained in:
parent
929069c1b6
commit
f2acab4496
21
load/bgm.lua
21
load/bgm.lua
@ -9,31 +9,38 @@ local current_bgm = nil
|
|||||||
local bgm_locked = false
|
local bgm_locked = false
|
||||||
|
|
||||||
function switchBGM(sound, subsound)
|
function switchBGM(sound, subsound)
|
||||||
if bgm_locked then return end
|
|
||||||
if current_bgm ~= nil then
|
if current_bgm ~= nil then
|
||||||
current_bgm:stop()
|
current_bgm:stop()
|
||||||
end
|
end
|
||||||
|
if bgm_locked or config.bgm_volume <= 0 then
|
||||||
|
current_bgm = nil
|
||||||
|
elseif sound ~= nil then
|
||||||
if subsound ~= nil then
|
if subsound ~= nil then
|
||||||
current_bgm = bgm[sound][subsound]
|
current_bgm = bgm[sound][subsound]
|
||||||
resetBGMFadeout()
|
else
|
||||||
elseif sound ~= nil then
|
|
||||||
current_bgm = bgm[sound]
|
current_bgm = bgm[sound]
|
||||||
resetBGMFadeout()
|
end
|
||||||
else
|
else
|
||||||
current_bgm = nil
|
current_bgm = nil
|
||||||
end
|
end
|
||||||
|
if current_bgm ~= nil then
|
||||||
|
resetBGMFadeout()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function switchBGMLoop(sound, subsound)
|
function switchBGMLoop(sound, subsound)
|
||||||
if bgm_locked then return end
|
|
||||||
switchBGM(sound, subsound)
|
switchBGM(sound, subsound)
|
||||||
current_bgm:setLooping(true)
|
if current_bgm then current_bgm:setLooping(true) end
|
||||||
end
|
end
|
||||||
|
|
||||||
function lockBGM()
|
function lockBGM()
|
||||||
bgm_locked = true
|
bgm_locked = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function unlockBGM()
|
||||||
|
bgm_locked = false
|
||||||
|
end
|
||||||
|
|
||||||
local fading_bgm = false
|
local fading_bgm = false
|
||||||
local fadeout_time = 0
|
local fadeout_time = 0
|
||||||
local total_fadeout_time = 0
|
local total_fadeout_time = 0
|
||||||
@ -53,7 +60,7 @@ function resetBGMFadeout(time)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function processBGMFadeout(dt)
|
function processBGMFadeout(dt)
|
||||||
if fading_bgm then
|
if current_bgm and fading_bgm then
|
||||||
fadeout_time = fadeout_time - dt
|
fadeout_time = fadeout_time - dt
|
||||||
if fadeout_time < 0 then
|
if fadeout_time < 0 then
|
||||||
fadeout_time = 0
|
fadeout_time = 0
|
||||||
|
@ -27,33 +27,37 @@ sounds = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function playSE(sound, subsound)
|
function playSE(sound, subsound)
|
||||||
if subsound == nil then
|
if sound ~= nil then
|
||||||
sounds[sound]:setVolume(config.sfx_volume)
|
if subsound ~= nil then
|
||||||
if sounds[sound]:isPlaying() then
|
|
||||||
sounds[sound]:stop()
|
|
||||||
end
|
|
||||||
sounds[sound]:play()
|
|
||||||
else
|
|
||||||
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||||
if sounds[sound][subsound]:isPlaying() then
|
if sounds[sound][subsound]:isPlaying() then
|
||||||
sounds[sound][subsound]:stop()
|
sounds[sound][subsound]:stop()
|
||||||
end
|
end
|
||||||
sounds[sound][subsound]:play()
|
sounds[sound][subsound]:play()
|
||||||
|
else
|
||||||
|
sounds[sound]:setVolume(config.sfx_volume)
|
||||||
|
if sounds[sound]:isPlaying() then
|
||||||
|
sounds[sound]:stop()
|
||||||
|
end
|
||||||
|
sounds[sound]:play()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function playSEOnce(sound, subsound)
|
function playSEOnce(sound, subsound)
|
||||||
if subsound == nil then
|
if sound ~= nil then
|
||||||
sounds[sound]:setVolume(config.sfx_volume)
|
if subsound ~= nil then
|
||||||
if sounds[sound]:isPlaying() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
sounds[sound]:play()
|
|
||||||
else
|
|
||||||
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
sounds[sound][subsound]:setVolume(config.sfx_volume)
|
||||||
if sounds[sound][subsound]:isPlaying() then
|
if sounds[sound][subsound]:isPlaying() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
sounds[sound][subsound]:play()
|
sounds[sound][subsound]:play()
|
||||||
|
else
|
||||||
|
sounds[sound]:setVolume(config.sfx_volume)
|
||||||
|
if sounds[sound]:isPlaying() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
sounds[sound]:play()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -42,62 +42,17 @@ function GameScene:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function GameScene:render()
|
function GameScene:render()
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
self.game:drawBackground()
|
||||||
love.graphics.draw(
|
self.game:drawFrame()
|
||||||
backgrounds[self.game:getBackground()],
|
|
||||||
0, 0, 0,
|
|
||||||
0.5, 0.5
|
|
||||||
)
|
|
||||||
|
|
||||||
-- game frame
|
|
||||||
if self.game.grid.width == 10 and self.game.grid.height == 24 then
|
|
||||||
love.graphics.draw(misc_graphics["frame"], 48, 64)
|
|
||||||
end
|
|
||||||
|
|
||||||
love.graphics.setColor(0, 0, 0, 200)
|
|
||||||
love.graphics.rectangle(
|
|
||||||
"fill", 64, 80,
|
|
||||||
16 * self.game.grid.width, 16 * (self.game.grid.height - 4)
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.game.grid.width ~= 10 or self.game.grid.height ~= 24 then
|
|
||||||
love.graphics.setColor(174/255, 83/255, 76/255, 1)
|
|
||||||
love.graphics.setLineWidth(8)
|
|
||||||
love.graphics.line(
|
|
||||||
60,76,
|
|
||||||
68+16*self.game.grid.width,76,
|
|
||||||
68+16*self.game.grid.width,84+16*(self.game.grid.height-4),
|
|
||||||
60,84+16*(self.game.grid.height-4),
|
|
||||||
60,76
|
|
||||||
)
|
|
||||||
love.graphics.setColor(203/255, 137/255, 111/255, 1)
|
|
||||||
love.graphics.setLineWidth(4)
|
|
||||||
love.graphics.line(
|
|
||||||
60,76,
|
|
||||||
68+16*self.game.grid.width,76,
|
|
||||||
68+16*self.game.grid.width,84+16*(self.game.grid.height-4),
|
|
||||||
60,84+16*(self.game.grid.height-4),
|
|
||||||
60,76
|
|
||||||
)
|
|
||||||
love.graphics.setLineWidth(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.game:drawGrid()
|
self.game:drawGrid()
|
||||||
if self.game.lcd > 0 then self.game:drawLineClearAnimation() end
|
if self.game.lcd > 0 then self.game:drawLineClearAnimation() end
|
||||||
self.game:drawPiece()
|
self.game:drawPiece()
|
||||||
self.game:drawNextQueue(self.ruleset)
|
self.game:drawNextQueue(self.ruleset)
|
||||||
self.game:drawScoringInfo()
|
self.game:drawScoringInfo()
|
||||||
|
self.game:drawReadyGo()
|
||||||
-- ready/go graphics
|
|
||||||
|
|
||||||
if self.game.ready_frames <= 100 and self.game.ready_frames > 52 then
|
|
||||||
love.graphics.draw(misc_graphics["ready"], 144 - 50, 240 - 14)
|
|
||||||
elseif self.game.ready_frames <= 50 and self.game.ready_frames > 2 then
|
|
||||||
love.graphics.draw(misc_graphics["go"], 144 - 27, 240 - 14)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.game:drawCustom()
|
self.game:drawCustom()
|
||||||
|
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.setFont(font_3x5_2)
|
love.graphics.setFont(font_3x5_2)
|
||||||
if config.gamesettings.display_gamemode == 1 then
|
if config.gamesettings.display_gamemode == 1 then
|
||||||
love.graphics.printf(self.game.name .. " - " .. self.ruleset.name, 0, 460, 640, "left")
|
love.graphics.printf(self.game.name .. " - " .. self.ruleset.name, 0, 460, 640, "left")
|
||||||
|
@ -118,6 +118,7 @@ function Piece:lockIfBottomed(grid)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Piece:addGravity(gravity, grid, classic_lock)
|
function Piece:addGravity(gravity, grid, classic_lock)
|
||||||
|
gravity = gravity / (self.big and 2 or 1)
|
||||||
local new_gravity = self.gravity + gravity
|
local new_gravity = self.gravity + gravity
|
||||||
if self:isDropBlocked(grid) then
|
if self:isDropBlocked(grid) then
|
||||||
if classic_lock then
|
if classic_lock then
|
||||||
|
@ -325,11 +325,13 @@ function GameMode:onPieceEnter() end
|
|||||||
function GameMode:onHold() end
|
function GameMode:onHold() end
|
||||||
|
|
||||||
function GameMode:onSoftDrop(dropped_row_count)
|
function GameMode:onSoftDrop(dropped_row_count)
|
||||||
self.drop_bonus = self.drop_bonus + 1 * dropped_row_count
|
self.drop_bonus = self.drop_bonus + (
|
||||||
|
(self.piece.big and 2 or 1) * dropped_row_count
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:onHardDrop(dropped_row_count)
|
function GameMode:onHardDrop(dropped_row_count)
|
||||||
self.drop_bonus = self.drop_bonus + 2 * dropped_row_count
|
self:onSoftDrop(dropped_row_count * 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GameMode:onGameOver()
|
function GameMode:onGameOver()
|
||||||
@ -838,6 +840,61 @@ function GameMode:drawSectionTimesWithSplits(current_section, section_limit)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GameMode:drawBackground()
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.draw(
|
||||||
|
backgrounds[self:getBackground()],
|
||||||
|
0, 0, 0,
|
||||||
|
0.5, 0.5
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameMode:drawFrame()
|
||||||
|
-- game frame
|
||||||
|
if self.grid.width == 10 and self.grid.height == 24 then
|
||||||
|
love.graphics.draw(misc_graphics["frame"], 48, 64)
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.setColor(0, 0, 0, 200)
|
||||||
|
love.graphics.rectangle(
|
||||||
|
"fill", 64, 80,
|
||||||
|
16 * self.grid.width, 16 * (self.grid.height - 4)
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.grid.width ~= 10 or self.grid.height ~= 24 then
|
||||||
|
love.graphics.setColor(174/255, 83/255, 76/255, 1)
|
||||||
|
love.graphics.setLineWidth(8)
|
||||||
|
love.graphics.line(
|
||||||
|
60,76,
|
||||||
|
68+16*self.grid.width,76,
|
||||||
|
68+16*self.grid.width,84+16*(self.grid.height-4),
|
||||||
|
60,84+16*(self.grid.height-4),
|
||||||
|
60,76
|
||||||
|
)
|
||||||
|
love.graphics.setColor(203/255, 137/255, 111/255, 1)
|
||||||
|
love.graphics.setLineWidth(4)
|
||||||
|
love.graphics.line(
|
||||||
|
60,76,
|
||||||
|
68+16*self.grid.width,76,
|
||||||
|
68+16*self.grid.width,84+16*(self.grid.height-4),
|
||||||
|
60,84+16*(self.grid.height-4),
|
||||||
|
60,76
|
||||||
|
)
|
||||||
|
love.graphics.setLineWidth(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameMode:drawReadyGo()
|
||||||
|
-- ready/go graphics
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
|
||||||
|
if self.ready_frames <= 100 and self.ready_frames > 52 then
|
||||||
|
love.graphics.draw(misc_graphics["ready"], 144 - 50, 240 - 14)
|
||||||
|
elseif self.ready_frames <= 50 and self.ready_frames > 2 then
|
||||||
|
love.graphics.draw(misc_graphics["go"], 144 - 27, 240 - 14)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function GameMode:drawCustom() end
|
function GameMode:drawCustom() end
|
||||||
|
|
||||||
return GameMode
|
return GameMode
|
||||||
|
@ -161,11 +161,6 @@ function Ruleset:dropPiece(
|
|||||||
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
|
inputs, piece, grid, gravity, drop_speed, drop_locked, hard_drop_locked,
|
||||||
hard_drop_enabled, additive_gravity, classic_lock
|
hard_drop_enabled, additive_gravity, classic_lock
|
||||||
)
|
)
|
||||||
if piece.big then
|
|
||||||
gravity = gravity / 2
|
|
||||||
drop_speed = drop_speed / 2
|
|
||||||
end
|
|
||||||
|
|
||||||
local y = piece.position.y
|
local y = piece.position.y
|
||||||
if inputs["down"] == true and drop_locked == false then
|
if inputs["down"] == true and drop_locked == false then
|
||||||
if additive_gravity then
|
if additive_gravity then
|
||||||
|
Loading…
Reference in New Issue
Block a user