Tween bubble moving to launcher and next bubble

main
Tyler Scott 2022-02-13 08:12:28 +07:00
parent cf0ff8a026
commit c03a9462a9
1 changed files with 54 additions and 14 deletions

View File

@ -350,6 +350,7 @@ local function start_level()
velocity_y = 0 velocity_y = 0
} }
game.next_bubble_type = get_next_bubble_type(2, bubble_types) game.next_bubble_type = get_next_bubble_type(2, bubble_types)
game.next_bubble_scale = 1
game.show_aim_guide = true game.show_aim_guide = true
game.aim_guide = {} game.aim_guide = {}
@ -470,6 +471,36 @@ function love.update(dt)
end end
end end
if game.current_bubble and game.current_bubble.tween then
game.current_bubble.tween.t = game.current_bubble.tween.t + 1
if game.current_bubble.tween.t == game.current_bubble.tween.d then
game.current_bubble.tween = nil
game.current_bubble.x = game.launcher_x
else
game.current_bubble.x = easing.outBack(
game.current_bubble.tween.t,
game.current_bubble.tween.b,
game.current_bubble.tween.c,
game.current_bubble.tween.d
)
end
end
if game.next_bubble_tween then
game.next_bubble_tween.t = game.next_bubble_tween.t + 1
if game.next_bubble_tween.t == game.next_bubble_tween.d then
game.next_bubble_tween = nil
game.next_bubble_scale = 1
else
game.next_bubble_scale = easing.outBack(
game.next_bubble_tween.t,
game.next_bubble_tween.b,
game.next_bubble_tween.c,
game.next_bubble_tween.d
)
end
end
if game.ceiling_drop_tween then if game.ceiling_drop_tween then
local old_y = game.ceiling_bottom local old_y = game.ceiling_bottom
game.ceiling_drop_tween.t = game.ceiling_drop_tween.t + 1 game.ceiling_drop_tween.t = game.ceiling_drop_tween.t + 1
@ -617,13 +648,21 @@ function love.update(dt)
end end
-- get next bubble -- get next bubble
game.current_bubble = { game.current_bubble = {
x = game.launcher_x, x = game.launcher_x + game.bubble_diameter * 2,
y = game.launcher_y, y = game.launcher_y,
bubble_type = game.next_bubble_type, bubble_type = game.next_bubble_type,
velocity_x = 0, velocity_x = 0,
velocity_y = 0 velocity_y = 0
} }
game.next_bubble_type = get_next_bubble_type(game.bubbles_launched+2, bubble_types) game.current_bubble.tween = {
t = 0,
d = 30,
b = game.current_bubble.x,
c = game.launcher_x - game.current_bubble.x
}
game.next_bubble_type = get_next_bubble_type(game.bubbles_launched+1, bubble_types)
game.next_bubble_scale = 0
game.next_bubble_tween = {t = 0, d = 30, b = 0, c = 1}
end end
end end
end end
@ -822,6 +861,19 @@ function love.draw(alpha)
end end
end end
-- draw upcoming bubble
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(
game.bubble_images[game.next_bubble_type],
game.launcher_x + game.bubble_diameter * 2,
game.launcher_y,
0,
game.next_bubble_scale,
game.next_bubble_scale,
game.bubble_radius,
game.bubble_radius
)
-- draw current bubble -- draw current bubble
-- if moving, extrapolate position based on alpha value from love.run -- if moving, extrapolate position based on alpha value from love.run
if game.current_bubble then if game.current_bubble then
@ -838,18 +890,6 @@ function love.draw(alpha)
) )
end end
-- draw upcoming bubble
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(
game.bubble_images[game.next_bubble_type],
game.launcher_x + game.bubble_diameter * 2,
game.launcher_y,
0,
1,
1,
game.bubble_radius,
game.bubble_radius
)
if game.game_over then if game.game_over then
love.graphics.setShader() love.graphics.setShader()