19 lines
494 B
Lua
19 lines
494 B
Lua
|
|
local phys = {
|
||
|
|
tau = 2 * math.pi
|
||
|
|
}
|
||
|
|
|
||
|
|
-- returns true if the two actors intersect
|
||
|
|
function phys.intersects(actor1, actor2)
|
||
|
|
return (actor1.x - actor2.x) ^ 2 + (actor1.y - actor2.y) ^ 2 <= (actor1.radius + actor2.radius) ^ 2
|
||
|
|
end
|
||
|
|
|
||
|
|
-- updates the actor's location by applying the passage of time
|
||
|
|
-- TODO spin
|
||
|
|
function phys.update(actor, dt)
|
||
|
|
local dv = actor.speed * dt
|
||
|
|
actor.x = actor.x + math.cos(actor.angle) * dv
|
||
|
|
actor.y = actor.y + math.sin(actor.angle) * dv
|
||
|
|
end
|
||
|
|
|
||
|
|
return phys
|