12 lines
399 B
Lua
12 lines
399 B
Lua
local sqrt = math.sqrt
|
|
|
|
velocitySystem = tiny.filteredSystem({ position = T.XyPair, velocity = T.XyPair }, function(e, dt)
|
|
if sqrt((e.velocity.x * e.velocity.x) + (e.velocity.y * e.velocity.y)) < 0.1 then
|
|
e.velocity = nil
|
|
world:addEntity(e)
|
|
else
|
|
e.position.x = e.position.x + (e.velocity.x * dt)
|
|
e.position.y = e.position.y + (e.velocity.y * dt)
|
|
end
|
|
end)
|