diff --git a/main.lua b/main.lua index 7b0f73d..ee62ee7 100644 --- a/main.lua +++ b/main.lua @@ -350,6 +350,7 @@ local function start_level() velocity_y = 0 } game.next_bubble_type = get_next_bubble_type(2, bubble_types) + game.next_bubble_scale = 1 game.show_aim_guide = true game.aim_guide = {} @@ -470,6 +471,36 @@ function love.update(dt) end end + if 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 local old_y = game.ceiling_bottom game.ceiling_drop_tween.t = game.ceiling_drop_tween.t + 1 @@ -617,13 +648,21 @@ function love.update(dt) end -- get next bubble game.current_bubble = { - x = game.launcher_x, + x = game.launcher_x + game.bubble_diameter * 2, y = game.launcher_y, bubble_type = game.next_bubble_type, velocity_x = 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 @@ -822,6 +861,19 @@ 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, + game.next_bubble_scale, + game.next_bubble_scale, + game.bubble_radius, + game.bubble_radius + ) + -- draw current bubble -- if moving, extrapolate position based on alpha value from love.run if game.current_bubble then @@ -838,18 +890,6 @@ function love.draw(alpha) ) 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 love.graphics.setShader()