Skip to content

Commit

Permalink
Rewrite countdown, fix week6 non-erect
Browse files Browse the repository at this point in the history
  • Loading branch information
GuglioIsStupid committed May 5, 2024
1 parent 96d11d6 commit 04b2eed
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 79 deletions.
11 changes: 11 additions & 0 deletions src/love/modules/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ CONSTANTS.WEEKS = {
["bounceIn"] = "in-bounce",
["bounceOut"] = "out-bounce",
["bounceInOut"] = "in-out-bounce"
},
COUNTDOWN_SOUNDS = {
"go",
"one",
"two",
"three"
},
COUNTDOWN_ANIMS = {
"go",
"set",
"ready"
}
}

Expand Down
46 changes: 22 additions & 24 deletions src/love/modules/graphics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,38 +398,36 @@ return {
beat = function(self, beat)
local beat = math.floor(beat) or 0
if self.isCharacter then
if beatHandler.onBeat() then
if not self.danceIdle then
if (not self:isAnimated() and util.startsWith(self:getAnimName(), "sing")) or (self:getAnimName() == "idle" or self:getAnimName() == "idle loop") then
if beat % self.danceSpeed == 0 then
if self.lastHit > 0 then
if beat % math.max(self.danceSpeed, 2) == 0 and self.lastHit + beatHandler.stepCrochet * self.singDuration <= musicTime then
self:animate("idle", false, function()
if self:isAnimName("idle loop") then
self:animate("idle loop", true)
end
end)
self.lastHit = 0
end
elseif beat % self.danceSpeed == 0 then
if not self.danceIdle then
if (not self:isAnimated() and util.startsWith(self:getAnimName(), "sing")) or (self:getAnimName() == "idle" or self:getAnimName() == "idle loop") then
if beat % self.danceSpeed == 0 then
if self.lastHit > 0 then
if beat % math.max(self.danceSpeed, 2) == 0 and self.lastHit + beatHandler.stepCrochet * self.singDuration <= musicTime then
self:animate("idle", false, function()
if self:isAnimName("idle loop") then
self:animate("idle loop", true)
end
end)
self.lastHit = 0
end
elseif beat % self.danceSpeed == 0 then
self:animate("idle", false, function()
if self:isAnimName("idle loop") then
self:animate("idle loop", true)
end
end)
end
end
else
if beat % self.danceSpeed == 0 then
if (not self:isAnimated() and util.startsWith(self:getAnimName(), "sing")) or (self:getAnimName() == "danceLeft" or self:getAnimName() == "danceRight" or (not self:isAnimated() and self:getAnimName() == "sad")) then
self.danced = not self.danced
if self.danced then
self:animate("danceLeft", false)
else
self:animate("danceRight", false)
end
end
end
else
if beat % self.danceSpeed == 0 then
if (not self:isAnimated() and util.startsWith(self:getAnimName(), "sing")) or (self:getAnimName() == "danceLeft" or self:getAnimName() == "danceRight" or (not self:isAnimated() and self:getAnimName() == "sad")) then
self.danced = not self.danced
if self.danced then
self:animate("danceLeft", false)
else
self:animate("danceRight", false)
end
end
end
end
Expand Down
98 changes: 44 additions & 54 deletions src/love/states/weeks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ local ratingTimers = {}
local useAltAnims
local option = "normal"

local countNum = 4 -- Used for countdown

return {
enter = function(self, option)
playMenuMusic = false
Expand Down Expand Up @@ -486,62 +488,48 @@ return {
end,

-- Gross countdown script
setupCountdown = function(self)
setupCountdown = function(self, countNumVal)
local countNumVal = countNumVal or 4
lastReportedPlaytime = 0
musicTime = (240 / bpm) * -1000

musicTime = ((60*4) / bpm) * -1000 -- countdown is 4 beats long
musicThres = 0

countingDown = true
countdownFade[1] = 0
audio.playSound(sounds.countdown.three)
Timer.after(
(60 / bpm),
function()
countdown:animate("ready")
countdownFade[1] = 1
audio.playSound(sounds.countdown.two)
Timer.tween(
(60 / bpm),
countdownFade,
{0},
"linear",
function()
countdown:animate("set")
countdownFade[1] = 1
audio.playSound(sounds.countdown.one)
Timer.tween(
(60 / bpm),
countdownFade,
{0},
"linear",
function()
countdown:animate("go")
countdownFade[1] = 1
audio.playSound(sounds.countdown.go)
Timer.tween(
(60 / bpm),
countdownFade,
{0},
"linear",
function()
countingDown = false

previousFrameTime = love.timer.getTime() * 1000
musicTime = 0
beatHandler.reset(0)

if inst then inst:play() end
if voicesBF then voicesBF:play() end
if voicesEnemy then voicesEnemy:play() end
end
)
end
)
if girlfriend then girlfriend:beat(countNumVal) end
if boyfriend then boyfriend:beat(countNumVal) end
if enemy then enemy:beat(countNumVal) end
if CONSTANTS.WEEKS.COUNTDOWN_SOUNDS[countNumVal] then audio.playSound(sounds.countdown[CONSTANTS.WEEKS.COUNTDOWN_SOUNDS[countNumVal]]) end
if countNumVal == 4 then
countdownFade[1] = 0
Timer.after(
(60/bpm), -- one beat
function()
self:setupCountdown(countNumVal - 1)
end
)
else
countdownFade[1] = 1
countdown:animate(CONSTANTS.WEEKS.COUNTDOWN_ANIMS[countNumVal])
Timer.tween(
(60/bpm),
countdownFade,
{0},
"linear",
function()
if countNumVal ~= 1 then self:setupCountdown(countNumVal - 1)
else
countingDown = false
previousFrameTime = love.timer.getTime() * 1000
musicTime = 0
beatHandler.reset(0)

if inst then inst:play() end
if voicesBF then voicesBF:play() end
if voicesEnemy then voicesEnemy:play() end
end
)
end
)
end
)
end
end,

update = function(self, dt)
Expand Down Expand Up @@ -731,9 +719,11 @@ return {
if enemy then enemy:update(dt) end
if boyfriend then boyfriend:update(dt) end

if boyfriend then boyfriend:beat(beatHandler.getBeat()) end
if enemy then enemy:beat(beatHandler.getBeat()) end
if girlfriend then girlfriend:beat(beatHandler.getBeat()) end
if beatHandler.onBeat() then
if boyfriend then boyfriend:beat(beatHandler.getBeat()) end
if enemy then enemy:beat(beatHandler.getBeat()) end
if girlfriend then girlfriend:beat(beatHandler.getBeat()) end
end
end,

judgeNote = function(self, msTiming)
Expand Down
2 changes: 1 addition & 1 deletion src/love/weeks/week6.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ return {
elseif song == 2 then
inst = love.audio.newSource("songs/roses/Inst" .. (hasErect and "-erect" or "") .. ".ogg", "stream")
voicesBF = love.audio.newSource("songs/roses/Voices-bf" .. (hasErect and "-pixel-erect" or "") .. ".ogg", "stream")
voicesEnemy = love.audio.newSource("songs/roses/Voices-senpai-angry" .. (hasErect and "-erect" or "") .. ".ogg", "stream")
voicesEnemy = love.audio.newSource("songs/roses/Voices-senpai" .. (hasErect and "-angry-erect" or "") .. ".ogg", "stream")
else
inst = love.audio.newSource("songs/senpai/Inst" .. (hasErect and "-erect" or "") .. ".ogg", "stream")
voicesBF = love.audio.newSource("songs/senpai/Voices-bf" .. (hasErect and "-pixel-erect" or "") .. ".ogg", "stream")
Expand Down

0 comments on commit 04b2eed

Please sign in to comment.