local world = require("world")
local sqrt = math.sqrt

world:filteredSystem("velocity", { position = T.XyPair, velocity = T.XyPair }, function(e, dt, _)
    if sqrt((e.velocity.x * e.velocity.x) + (e.velocity.y * e.velocity.y)) < 2 then
        -- velocity = nil
    else
        e.position.x = e.position.x + (e.velocity.x * dt)
        e.position.y = e.position.y + (e.velocity.y * dt)
    end
end)

world:filteredSystem("drag", { velocity = T.XyPair, drag = T.number }, function(e, dt, _)
    local currentDrag = e.drag * dt
    e.velocity.x = e.velocity.x - (e.velocity.x * currentDrag * dt)
    e.velocity.y = e.velocity.y - (e.velocity.y * currentDrag * dt)
end)