Compare commits
3 Commits
444e4305c5
...
0aa9418dc2
| Author | SHA1 | Date |
|---|---|---|
|
|
0aa9418dc2 | |
|
|
e84feb42fb | |
|
|
61b08d5293 |
76
main.lua
76
main.lua
|
|
@ -289,6 +289,16 @@ local function find_unattached_bubbles()
|
|||
return unattached
|
||||
end
|
||||
|
||||
-- don't allow aiming backwards or straight sideways
|
||||
local function clamp_launcher_angle(angle)
|
||||
if (angle >= 0 and angle <= tau / 4) or angle > tau * 25 / 26 then
|
||||
angle = tau * 25 / 26
|
||||
elseif angle > tau / 4 and angle < tau * 14 / 26 then
|
||||
angle = tau * 14 / 26
|
||||
end
|
||||
return angle
|
||||
end
|
||||
|
||||
local function start_level()
|
||||
game.game_over = false
|
||||
game.paused = false
|
||||
|
|
@ -444,29 +454,6 @@ function love.update(dt)
|
|||
end
|
||||
end
|
||||
|
||||
if game.paused or game.game_over then
|
||||
return
|
||||
end
|
||||
|
||||
if game.show_aim_guide then
|
||||
for i = 1, #game.aim_guide do
|
||||
local dot = game.aim_guide[i]
|
||||
if dot.tween then
|
||||
if dot.tween.delay == 0 then
|
||||
dot.tween.t = dot.tween.t + 1
|
||||
if dot.tween.t == dot.tween.d then
|
||||
dot.tween.t = 0
|
||||
else
|
||||
dot.x = easing.linear(dot.tween.t, dot.tween.b_x, dot.tween.c_x, dot.tween.d)
|
||||
dot.y = easing.linear(dot.tween.t, dot.tween.b_y, dot.tween.c_y, dot.tween.d)
|
||||
end
|
||||
else
|
||||
dot.tween.delay = dot.tween.delay - 1
|
||||
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
|
||||
|
|
@ -497,6 +484,29 @@ function love.update(dt)
|
|||
end
|
||||
end
|
||||
|
||||
if game.paused or game.game_over then
|
||||
return
|
||||
end
|
||||
|
||||
if game.show_aim_guide then
|
||||
for i = 1, #game.aim_guide do
|
||||
local dot = game.aim_guide[i]
|
||||
if dot.tween then
|
||||
if dot.tween.delay == 0 then
|
||||
dot.tween.t = dot.tween.t + 1
|
||||
if dot.tween.t == dot.tween.d then
|
||||
dot.tween.t = 0
|
||||
else
|
||||
dot.x = easing.linear(dot.tween.t, dot.tween.b_x, dot.tween.c_x, dot.tween.d)
|
||||
dot.y = easing.linear(dot.tween.t, dot.tween.b_y, dot.tween.c_y, dot.tween.d)
|
||||
end
|
||||
else
|
||||
dot.tween.delay = dot.tween.delay - 1
|
||||
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
|
||||
|
|
@ -965,6 +975,17 @@ function love.mousepressed(x, y, button, is_touch, presses)
|
|||
end
|
||||
end
|
||||
|
||||
function love.wheelmoved(x, y)
|
||||
if y ~= 0 then
|
||||
local angle = game.launcher_rotation
|
||||
angle = angle + (y < 0 and 0.01 or -0.01)
|
||||
game.launcher_rotation = clamp_launcher_angle(angle)
|
||||
if game.show_aim_guide then
|
||||
generate_aim_guide(game.launcher_rotation)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function love.mousemoved(x, y, dx, dy, is_touch)
|
||||
if not game.game_over then
|
||||
local diff_x = x - game.launcher_x
|
||||
|
|
@ -976,14 +997,7 @@ function love.mousemoved(x, y, dx, dy, is_touch)
|
|||
angle = angle + tau
|
||||
end
|
||||
|
||||
-- don't allow aiming backwards
|
||||
if (angle >= 0 and angle <= tau / 4) or angle >= tau * 25 / 26 then
|
||||
angle = tau * 25 / 26
|
||||
elseif angle >= tau / 4 and angle <= tau * 14 / 26 then
|
||||
angle = tau * 14 / 26
|
||||
end
|
||||
|
||||
game.launcher_rotation = angle
|
||||
game.launcher_rotation = clamp_launcher_angle(angle)
|
||||
|
||||
if game.show_aim_guide then
|
||||
generate_aim_guide(game.launcher_rotation)
|
||||
|
|
|
|||
Loading…
Reference in New Issue