Compare commits

..

No commits in common. "bfe12002e54a7399302d00809248eff75d870797" and "9a9bdf0232b45db4f0b6fcde8604c8a8a622f608" have entirely different histories.

1 changed files with 17 additions and 51 deletions

View File

@ -118,7 +118,7 @@ local function move_bubble(x, y, velocity_x, velocity_y)
local should_stop = false local should_stop = false
-- collision with ceiling -- collision with ceiling
if new_y - game.bubble_radius <= game.ceiling_bottom then if new_y - game.bubble_radius <= game.level_top then
should_stop = true should_stop = true
end end
@ -350,11 +350,6 @@ function love.load(arg)
} }
game.current_level = 1 game.current_level = 1
game.bubbles_launched = 0
game.ceiling_drops_after = 5
game.ceiling_drop_tween = nil
game.ceiling_should_drop = false
game.bubble_slots = load_level( game.bubble_slots = load_level(
game.levels[game.current_level], game.bubble_diameter, game.row_gap game.levels[game.current_level], game.bubble_diameter, game.row_gap
) )
@ -369,11 +364,10 @@ function love.load(arg)
game.level_top = game.bubble_radius game.level_top = game.bubble_radius
game.level_right = game.level_left + game.level_width game.level_right = game.level_left + game.level_width
game.level_bottom = game.level_top + game.level_height game.level_bottom = game.level_top + game.level_height
game.ceiling_bottom = game.level_top
for i = 1, #game.bubble_slots do for i = 1, #game.bubble_slots do
game.bubble_slots[i].x = game.bubble_slots[i].x + game.level_left game.bubble_slots[i].x = game.bubble_slots[i].x + game.level_left
game.bubble_slots[i].y = game.bubble_slots[i].y + game.ceiling_bottom game.bubble_slots[i].y = game.bubble_slots[i].y + game.level_top
end end
game.launcher_image = love.graphics.newImage('images/launcher.png') game.launcher_image = love.graphics.newImage('images/launcher.png')
@ -394,10 +388,11 @@ function love.load(arg)
bubble_types[#bubble_types+1] = bubble_type bubble_types[#bubble_types+1] = bubble_type
end end
end end
game.next_bubble_index = 1
game.next_bubble = { game.next_bubble = {
x = game.launcher_x, x = game.launcher_x,
y = game.launcher_y, y = game.launcher_y,
bubble_type = get_next_bubble_type(game.bubbles_launched+1, bubble_types), bubble_type = get_next_bubble_type(game.next_bubble_index, bubble_types),
velocity_x = 0, velocity_x = 0,
velocity_y = 0 velocity_y = 0
} }
@ -430,23 +425,6 @@ function love.update(dt)
end end
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
game.ceiling_bottom = easing.outBack(
game.ceiling_drop_tween.t,
game.ceiling_drop_tween.b,
game.ceiling_drop_tween.c,
game.ceiling_drop_tween.d
)
for i = 1, #game.bubble_slots do
game.bubble_slots[i].y = game.bubble_slots[i].y + (game.ceiling_bottom - old_y)
end
if game.ceiling_drop_tween.t == game.ceiling_drop_tween.d then
game.ceiling_drop_tween = nil
end
end
if game.next_bubble and if game.next_bubble and
(game.next_bubble.velocity_x ~= 0 or game.next_bubble.velocity_y ~= 0) then (game.next_bubble.velocity_x ~= 0 or game.next_bubble.velocity_y ~= 0) then
@ -467,15 +445,6 @@ function love.update(dt)
game.bubble_slots[movement_info.nearest_slot_index].bubble_type = game.bubble_slots[movement_info.nearest_slot_index].bubble_type =
game.next_bubble.bubble_type game.next_bubble.bubble_type
if game.ceiling_should_drop then
game.ceiling_drop_tween = {
t = 0,
d = 30,
b = game.ceiling_bottom,
c = game.bubble_diameter
}
end
local matches = find_matches(movement_info.nearest_slot_index) local matches = find_matches(movement_info.nearest_slot_index)
if #matches >= 3 then if #matches >= 3 then
game.next_bubble = nil game.next_bubble = nil
@ -492,7 +461,7 @@ function love.update(dt)
alpha = 1.0 alpha = 1.0
} }
game.bubble_slots[index].bubble_type = 0 game.bubble_slots[index].bubble_type = 0
local points = (i + 1) ^ 2 local points = i * 5
game.score = game.score + points game.score = game.score + points
game.points_display[#game.points_display+1] = { game.points_display[#game.points_display+1] = {
points = points, points = points,
@ -554,10 +523,11 @@ function love.update(dt)
end end
end end
-- get next bubble -- get next bubble
game.next_bubble_index = game.next_bubble_index + 1
game.next_bubble = { game.next_bubble = {
x = game.launcher_x, x = game.launcher_x,
y = game.launcher_y, y = game.launcher_y,
bubble_type = get_next_bubble_type(game.bubbles_launched+1, bubble_types), bubble_type = get_next_bubble_type(game.next_bubble_index, bubble_types),
velocity_x = 0, velocity_x = 0,
velocity_y = 0 velocity_y = 0
} }
@ -642,6 +612,13 @@ function love.draw(alpha)
game.bubble_radius, game.bubble_radius,
game.bubble_radius game.bubble_radius
) )
else
love.graphics.circle(
'line',
slot.x,
slot.y,
game.bubble_radius
)
end end
end end
@ -650,9 +627,9 @@ function love.draw(alpha)
love.graphics.rectangle( love.graphics.rectangle(
'line', 'line',
game.level_left, game.level_left,
game.ceiling_bottom, game.level_top,
game.level_width, game.level_width,
game.level_height - game.ceiling_bottom game.level_height
) )
-- draw launcher -- draw launcher
@ -755,23 +732,12 @@ function love.draw(alpha)
end end
function love.mousepressed(x, y, button, is_touch, presses) function love.mousepressed(x, y, button, is_touch, presses)
if button == 1 and game.next_bubble and if button == 1 and game.next_bubble then
game.next_bubble.x == game.launcher_x and
game.next_bubble.y == game.launcher_y and
game.next_bubble.velocity_x == 0 and
game.next_bubble.velocity_y == 0 then
local diff_x = x - game.launcher_x local diff_x = x - game.launcher_x
local diff_y = y - game.launcher_y local diff_y = y - game.launcher_y
local dist = math.sqrt(diff_x * diff_x + diff_y * diff_y) local dist = math.sqrt(diff_x * diff_x + diff_y * diff_y)
game.next_bubble.velocity_x = diff_x / dist * game.bubble_speed game.next_bubble.velocity_x = diff_x / dist * game.bubble_speed
game.next_bubble.velocity_y = diff_y / dist * game.bubble_speed game.next_bubble.velocity_y = diff_y / dist * game.bubble_speed
game.bubbles_launched = game.bubbles_launched + 1
-- if ceiling_should_drop is true, it will create a tween to drop the
-- ceiling (and bubbles) after the bubble that was just launched comes to a
-- stop in love.update()
game.ceiling_should_drop = game.bubbles_launched % game.ceiling_drops_after == 0
end end
end end