fix atan issue

the love2d that I'm using doesn't have the new atan arity lol
This commit is contained in:
Donald Ball 2025-11-17 20:21:42 -05:00
parent 9cdf032c39
commit f5df911707
3 changed files with 40 additions and 23 deletions

View file

@ -19,12 +19,10 @@ function phys.update(actor, dt)
end
function phys.rotate(actor, angle)
actor.angle = (actor.angle + angle) % phys.tau
actor.facing = (actor.facing + angle) % phys.tau
end
function phys.apply(actor, force)
assert(actor.speed >= 0)
assert(force.speed >= 0)
local ax = math.cos(actor.angle) * actor.speed
local ay = math.sin(actor.angle) * actor.speed
local fx = math.cos(force.angle) * force.speed
@ -33,7 +31,7 @@ function phys.apply(actor, force)
local y = ay + fy
local speed = math.sqrt(x ^ 2 + y ^ 2)
local angle = math.atan(y, x) % phys.tau
local angle = math.atan2(y, x) % phys.tau
actor.speed = speed
actor.angle = angle
end