Allow swapping current and next bubbles
parent
0aa9418dc2
commit
f41c6e3a91
95
main.lua
95
main.lua
|
|
@ -355,8 +355,12 @@ local function start_level()
|
||||||
velocity_x = 0,
|
velocity_x = 0,
|
||||||
velocity_y = 0
|
velocity_y = 0
|
||||||
}
|
}
|
||||||
game.next_bubble_type = get_next_bubble_type(2, bubble_types)
|
game.next_bubble = {
|
||||||
game.next_bubble_scale = 1
|
x = game.launcher_x + game.bubble_diameter * 2,
|
||||||
|
y = game.launcher_y,
|
||||||
|
bubble_type = get_next_bubble_type(2, bubble_types),
|
||||||
|
scale = 1
|
||||||
|
}
|
||||||
|
|
||||||
game.show_aim_guide = true
|
game.show_aim_guide = true
|
||||||
game.aim_guide = {}
|
game.aim_guide = {}
|
||||||
|
|
@ -454,33 +458,57 @@ function love.update(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if game.current_bubble and game.current_bubble.tween then
|
if game.current_bubble and game.current_bubble_tween then
|
||||||
game.current_bubble.tween.t = game.current_bubble.tween.t + 1
|
game.current_bubble_tween.t = game.current_bubble_tween.t + 1
|
||||||
if game.current_bubble.tween.t == game.current_bubble.tween.d then
|
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.x = easing.outBack(
|
||||||
game.current_bubble.tween.t,
|
game.current_bubble_tween.t,
|
||||||
game.current_bubble.tween.b,
|
game.current_bubble_tween.b,
|
||||||
game.current_bubble.tween.c,
|
game.current_bubble_tween.c,
|
||||||
game.current_bubble.tween.d
|
game.current_bubble_tween.d
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
game.current_bubble_tween = nil
|
||||||
|
game.current_bubble.x = game.launcher_x
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if game.next_bubble_tween then
|
if game.next_bubble_tween then
|
||||||
game.next_bubble_tween.t = game.next_bubble_tween.t + 1
|
game.next_bubble_tween.t = game.next_bubble_tween.t + 1
|
||||||
if game.next_bubble_tween.t == game.next_bubble_tween.d then
|
if game.next_bubble_tween.t < game.next_bubble_tween.d then
|
||||||
game.next_bubble_tween = nil
|
game.next_bubble.scale = easing.outBack(
|
||||||
game.next_bubble_scale = 1
|
|
||||||
else
|
|
||||||
game.next_bubble_scale = easing.outBack(
|
|
||||||
game.next_bubble_tween.t,
|
game.next_bubble_tween.t,
|
||||||
game.next_bubble_tween.b,
|
game.next_bubble_tween.b,
|
||||||
game.next_bubble_tween.c,
|
game.next_bubble_tween.c,
|
||||||
game.next_bubble_tween.d
|
game.next_bubble_tween.d
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
game.next_bubble_tween = nil
|
||||||
|
game.next_bubble.scale = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if game.bubble_swap_tween then
|
||||||
|
game.bubble_swap_tween.t = game.bubble_swap_tween.t + 1
|
||||||
|
if game.bubble_swap_tween.t < game.bubble_swap_tween.d then
|
||||||
|
game.current_bubble.x = easing.outBack(
|
||||||
|
game.bubble_swap_tween.t,
|
||||||
|
game.bubble_swap_tween.b1,
|
||||||
|
game.bubble_swap_tween.c1,
|
||||||
|
game.bubble_swap_tween.d
|
||||||
|
)
|
||||||
|
game.next_bubble.x = easing.outBack(
|
||||||
|
game.bubble_swap_tween.t,
|
||||||
|
game.bubble_swap_tween.b2,
|
||||||
|
game.bubble_swap_tween.c2,
|
||||||
|
game.bubble_swap_tween.d
|
||||||
|
)
|
||||||
|
else
|
||||||
|
game.bubble_swap_tween = nil
|
||||||
|
game.next_bubble.bubble_type, game.current_bubble.bubble_type =
|
||||||
|
game.current_bubble.bubble_type, game.next_bubble.bubble_type
|
||||||
|
game.current_bubble.x = game.launcher_x
|
||||||
|
game.next_bubble.x = game.launcher_x + game.bubble_diameter * 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -656,18 +684,18 @@ function love.update(dt)
|
||||||
game.current_bubble = {
|
game.current_bubble = {
|
||||||
x = game.launcher_x + game.bubble_diameter * 2,
|
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.bubble_type,
|
||||||
velocity_x = 0,
|
velocity_x = 0,
|
||||||
velocity_y = 0
|
velocity_y = 0
|
||||||
}
|
}
|
||||||
game.current_bubble.tween = {
|
game.current_bubble_tween = {
|
||||||
t = 0,
|
t = 0,
|
||||||
d = 30,
|
d = 30,
|
||||||
b = game.current_bubble.x,
|
b = game.current_bubble.x,
|
||||||
c = game.launcher_x - 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.bubble_type = get_next_bubble_type(game.bubbles_launched+1, bubble_types)
|
||||||
game.next_bubble_scale = 0
|
game.next_bubble.scale = 0
|
||||||
game.next_bubble_tween = {t = 0, d = 30, b = 0, c = 1}
|
game.next_bubble_tween = {t = 0, d = 30, b = 0, c = 1}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -870,12 +898,12 @@ function love.draw(alpha)
|
||||||
-- draw upcoming bubble
|
-- draw upcoming bubble
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
game.bubble_images[game.next_bubble_type],
|
game.bubble_images[game.next_bubble.bubble_type],
|
||||||
game.launcher_x + game.bubble_diameter * 2,
|
game.next_bubble.x,
|
||||||
game.launcher_y,
|
game.next_bubble.y,
|
||||||
0,
|
0,
|
||||||
game.next_bubble_scale,
|
game.next_bubble.scale,
|
||||||
game.next_bubble_scale,
|
game.next_bubble.scale,
|
||||||
game.bubble_radius,
|
game.bubble_radius,
|
||||||
game.bubble_radius
|
game.bubble_radius
|
||||||
)
|
)
|
||||||
|
|
@ -1010,6 +1038,21 @@ function love.keypressed(key, scan_code, is_repeat)
|
||||||
love.event.quit()
|
love.event.quit()
|
||||||
elseif game.game_over or key == 'r' then
|
elseif game.game_over or key == 'r' then
|
||||||
start_level()
|
start_level()
|
||||||
|
elseif key == 's' then
|
||||||
|
if game.current_bubble and
|
||||||
|
game.current_bubble.x == game.launcher_x and
|
||||||
|
game.current_bubble.y == game.launcher_y and
|
||||||
|
game.current_bubble.velocity_x == 0 and
|
||||||
|
game.current_bubble.velocity_y == 0 then
|
||||||
|
game.bubble_swap_tween = {
|
||||||
|
t = 0,
|
||||||
|
d = 30,
|
||||||
|
b1 = game.launcher_x,
|
||||||
|
b2 = game.launcher_x + game.bubble_diameter * 2,
|
||||||
|
c1 = game.bubble_diameter * 2,
|
||||||
|
c2 = -game.bubble_diameter * 2
|
||||||
|
}
|
||||||
|
end
|
||||||
elseif key == 'space' then
|
elseif key == 'space' then
|
||||||
game.paused = not game.paused
|
game.paused = not game.paused
|
||||||
elseif key == 'n' and game.paused then
|
elseif key == 'n' and game.paused then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue