Change fade to grey to not use a tween

main
Tyler Scott 2022-02-12 17:11:48 +07:00
parent a6febca64e
commit 22ce65d003
1 changed files with 13 additions and 13 deletions

View File

@ -305,7 +305,7 @@ function love.load(arg)
game.game_over_image = love.graphics.newImage('images/game_over.png')
game.game_over = false
game.fade_to_grey_tween = {p = 1.0}
game.fade_to_grey = {time = 0, duration = 120, progress = 0.0}
game.paused = false
game.frame_by_frame = false
@ -426,15 +426,13 @@ function love.load(arg)
end
function love.update(dt)
if game.game_over and game.fade_to_grey_tween.p < 1.0 then
game.fade_to_grey_tween.t = game.fade_to_grey_tween.t + 1
game.fade_to_grey_tween.p = easing.linear(
game.fade_to_grey_tween.t,
game.fade_to_grey_tween.b,
game.fade_to_grey_tween.c,
game.fade_to_grey_tween.d
)
game.shader:send("progress", game.fade_to_grey_tween.p)
if game.game_over then
if game.fade_to_grey.time < game.fade_to_grey.duration then
game.fade_to_grey.time = game.fade_to_grey.time + 1
game.fade_to_grey.progress =
game.fade_to_grey.time / game.fade_to_grey.duration
game.shader:send("progress", game.fade_to_grey.progress)
end
end
if game.paused or game.game_over then
@ -475,7 +473,8 @@ function love.update(dt)
if game.bubble_slots[i].bubble_type ~= 0 and
game.bubble_slots[i].y > game.level_bottom then
game.game_over = true
game.fade_to_grey_tween = {t = 0, d = 120, b = 0, c = 1, p = 0.0}
game.fade_to_grey.time = 0
game.fade_to_grey.progress = 0.0
end
end
if game.game_over then
@ -523,7 +522,8 @@ function love.update(dt)
if #matches < 3 and game.current_bubble.y > game.level_bottom then
game.game_over = true
game.fade_to_grey_tween = {t = 0, d = 120, b = 0, c = 1, p = 0.0}
game.fade_to_grey.time = 0
game.fade_to_grey.progress = 0.0
return
end
@ -864,7 +864,7 @@ function love.draw(alpha)
end
-- draw game over
if game.game_over and game.fade_to_grey_tween.p == 1.0 then
if game.game_over and game.fade_to_grey.progress == 1.0 then
love.graphics.setColor(0, 0, 0, 0.8)
love.graphics.rectangle(
'fill',