Compare commits
No commits in common. "8578bb8877ad2f184cafa2b870a4adc129f9e141" and "bfe12002e54a7399302d00809248eff75d870797" have entirely different histories.
8578bb8877
...
bfe12002e5
140
main.lua
140
main.lua
|
|
@ -301,8 +301,6 @@ function love.load(arg)
|
||||||
game.score_font = love.graphics.setNewFont(50)
|
game.score_font = love.graphics.setNewFont(50)
|
||||||
game.points_font = love.graphics.newFont(30)
|
game.points_font = love.graphics.newFont(30)
|
||||||
|
|
||||||
game.game_over = false
|
|
||||||
game.fade_to_grey_tween = {p = 1.0}
|
|
||||||
game.paused = false
|
game.paused = false
|
||||||
game.frame_by_frame = false
|
game.frame_by_frame = false
|
||||||
|
|
||||||
|
|
@ -406,34 +404,10 @@ function love.load(arg)
|
||||||
|
|
||||||
game.bursting_bubbles = {}
|
game.bursting_bubbles = {}
|
||||||
game.falling_bubbles = {}
|
game.falling_bubbles = {}
|
||||||
|
|
||||||
game.shader = love.graphics.newShader [[
|
|
||||||
uniform float progress;
|
|
||||||
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
|
|
||||||
{
|
|
||||||
vec4 pixel = Texel(texture, texture_coords);
|
|
||||||
number average = (pixel.r + pixel.b + pixel.g) / 3.0;
|
|
||||||
pixel.r = pixel.r + (average-pixel.r) * progress;
|
|
||||||
pixel.g = pixel.g + (average-pixel.g) * progress;
|
|
||||||
pixel.b = pixel.b + (average-pixel.b) * progress;
|
|
||||||
return pixel;
|
|
||||||
}
|
|
||||||
]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
if game.game_over and game.fade_to_grey_tween.p < 1.0 then
|
if game.paused 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)
|
|
||||||
end
|
|
||||||
|
|
||||||
if game.paused or game.game_over then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -465,17 +439,8 @@ function love.update(dt)
|
||||||
game.ceiling_drop_tween.c,
|
game.ceiling_drop_tween.c,
|
||||||
game.ceiling_drop_tween.d
|
game.ceiling_drop_tween.d
|
||||||
)
|
)
|
||||||
local diff_y = game.ceiling_bottom - old_y
|
|
||||||
for i = 1, #game.bubble_slots do
|
for i = 1, #game.bubble_slots do
|
||||||
game.bubble_slots[i].y = game.bubble_slots[i].y + diff_y
|
game.bubble_slots[i].y = game.bubble_slots[i].y + (game.ceiling_bottom - old_y)
|
||||||
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}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if game.game_over then
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
if game.ceiling_drop_tween.t == game.ceiling_drop_tween.d then
|
if game.ceiling_drop_tween.t == game.ceiling_drop_tween.d then
|
||||||
game.ceiling_drop_tween = nil
|
game.ceiling_drop_tween = nil
|
||||||
|
|
@ -507,18 +472,11 @@ function love.update(dt)
|
||||||
t = 0,
|
t = 0,
|
||||||
d = 30,
|
d = 30,
|
||||||
b = game.ceiling_bottom,
|
b = game.ceiling_bottom,
|
||||||
c = game.row_gap
|
c = game.bubble_diameter
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local matches = find_matches(movement_info.nearest_slot_index)
|
local matches = find_matches(movement_info.nearest_slot_index)
|
||||||
|
|
||||||
if #matches < 3 and game.next_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}
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if #matches >= 3 then
|
if #matches >= 3 then
|
||||||
game.next_bubble = nil
|
game.next_bubble = nil
|
||||||
|
|
||||||
|
|
@ -671,30 +629,6 @@ function love.draw(alpha)
|
||||||
love.graphics.draw(game.background_image, 0, 0)
|
love.graphics.draw(game.background_image, 0, 0)
|
||||||
love.graphics.draw(game.background_image, game.background_width, 0)
|
love.graphics.draw(game.background_image, game.background_width, 0)
|
||||||
|
|
||||||
-- draw walls
|
|
||||||
love.graphics.setColor(0, 0, 0, 1)
|
|
||||||
love.graphics.rectangle(
|
|
||||||
'line',
|
|
||||||
game.level_left,
|
|
||||||
game.level_top,
|
|
||||||
game.level_width,
|
|
||||||
game.level_height,
|
|
||||||
game.bubble_radius,
|
|
||||||
game.bubble_radius
|
|
||||||
)
|
|
||||||
if game.ceiling_bottom > game.level_top then
|
|
||||||
love.graphics.line(
|
|
||||||
game.level_left,
|
|
||||||
game.ceiling_bottom,
|
|
||||||
game.level_right,
|
|
||||||
game.ceiling_bottom
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
if game.game_over then
|
|
||||||
love.graphics.setShader(game.shader)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- draw stationary bubbles
|
-- draw stationary bubbles
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
for i = 1, #game.bubble_slots do
|
for i = 1, #game.bubble_slots do
|
||||||
|
|
@ -711,6 +645,16 @@ function love.draw(alpha)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- draw walls
|
||||||
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
|
love.graphics.rectangle(
|
||||||
|
'line',
|
||||||
|
game.level_left,
|
||||||
|
game.ceiling_bottom,
|
||||||
|
game.level_width,
|
||||||
|
game.level_height - game.ceiling_bottom
|
||||||
|
)
|
||||||
|
|
||||||
-- draw launcher
|
-- draw launcher
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.draw(
|
love.graphics.draw(
|
||||||
|
|
@ -760,19 +704,6 @@ function love.draw(alpha)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw aim guide
|
|
||||||
if game.show_aim_guide then
|
|
||||||
love.graphics.setColor(0, 0, 0, 1)
|
|
||||||
for i = 1, #game.aim_guide - 1 do
|
|
||||||
love.graphics.circle(
|
|
||||||
'line',
|
|
||||||
game.aim_guide[i].x,
|
|
||||||
game.aim_guide[i].y,
|
|
||||||
game.aim_guide[i].radius
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- draw next bubble
|
-- draw next 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.next_bubble then
|
if game.next_bubble then
|
||||||
|
|
@ -789,10 +720,6 @@ function love.draw(alpha)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
if game.game_over then
|
|
||||||
love.graphics.setShader()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- draw score
|
-- draw score
|
||||||
love.graphics.setFont(game.score_font)
|
love.graphics.setFont(game.score_font)
|
||||||
love.graphics.setColor(0, 0, 0, 1)
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
|
|
@ -813,32 +740,22 @@ function love.draw(alpha)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw game over
|
-- draw aim guide
|
||||||
if game.game_over and game.fade_to_grey_tween.p == 1.0 then
|
if game.show_aim_guide then
|
||||||
love.graphics.setColor(0, 0, 0, 0.8)
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
love.graphics.rectangle(
|
for i = 1, #game.aim_guide - 1 do
|
||||||
'fill',
|
love.graphics.circle(
|
||||||
game.level_left + game.bubble_diameter,
|
'line',
|
||||||
game.window_height / 2 - 80,
|
game.aim_guide[i].x,
|
||||||
game.level_width - game.bubble_diameter * 2,
|
game.aim_guide[i].y,
|
||||||
160,
|
game.aim_guide[i].radius
|
||||||
20,
|
|
||||||
20
|
|
||||||
)
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
love.graphics.printf(
|
|
||||||
'YOU LOSE',
|
|
||||||
game.level_left,
|
|
||||||
game.window_height / 2 - 30,
|
|
||||||
game.level_width,
|
|
||||||
'center'
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousepressed(x, y, button, is_touch, presses)
|
function love.mousepressed(x, y, button, is_touch, presses)
|
||||||
if not game.game_over and button == 1 and game.next_bubble and
|
if button == 1 and game.next_bubble and
|
||||||
game.next_bubble.x == game.launcher_x and
|
game.next_bubble.x == game.launcher_x and
|
||||||
game.next_bubble.y == game.launcher_y and
|
game.next_bubble.y == game.launcher_y and
|
||||||
game.next_bubble.velocity_x == 0 and
|
game.next_bubble.velocity_x == 0 and
|
||||||
|
|
@ -846,8 +763,6 @@ function love.mousepressed(x, y, button, is_touch, presses)
|
||||||
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)
|
||||||
-- TODO: don't allow shooting backwards
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -861,19 +776,14 @@ function love.mousepressed(x, y, button, is_touch, presses)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousemoved(x, y, dx, dy, is_touch)
|
function love.mousemoved(x, y, dx, dy, is_touch)
|
||||||
if not game.game_over 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 rotation = math.atan2(diff_y, diff_x)
|
game.launcher_rotation = math.atan2(diff_y, diff_x)
|
||||||
if rotation >= -tau * 7 / 16 and rotation <= -tau / 16 then
|
|
||||||
game.launcher_rotation = rotation
|
|
||||||
end
|
|
||||||
|
|
||||||
if game.show_aim_guide then
|
if game.show_aim_guide then
|
||||||
generate_aim_guide(x, y)
|
generate_aim_guide(x, y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function love.keypressed(key, scan_code, is_repeat)
|
function love.keypressed(key, scan_code, is_repeat)
|
||||||
if key == 'escape' then
|
if key == 'escape' then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue