WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Lua, what is dt, dy, and dx

Submitted by barnettech on Thu, 01/31/2019 - 20:34

number dx
The amount moved along the x-axis since the last time love.mousemoved was called.
number dy
The amount moved along the y-axis since the last time love.mousemoved was called.

dt is the most common shorthand for delta-time, which is usually passed through love.update to represent the amount of time which has passed since it was last called. It is in seconds, but because of the speed of modern processors is usually smaller than 1 values like 0.01 are common.

so the ball will move accordingly every dt

function Ball:update(dt)
    self.x = self.x + self.dx * dt
    self.y = self.y + self.dy * dt
end

references: https://love2d.org/wiki/dt, https://love2d.org/wiki/love.mousemoved