modules/world: make speed relative to dt

This commit is contained in:
Kazhnuz 2019-04-22 12:02:52 +02:00
parent 93f710e0b0
commit a25e178628
2 changed files with 7 additions and 7 deletions

View file

@ -9,16 +9,16 @@ end
function Player:update(dt)
self.xsp, self.ysp = 0, 0
if self.keys["up"].isDown then
self.ysp = -120 * dt
self.ysp = -120
end
if self.keys["down"].isDown then
self.ysp = 120 * dt
self.ysp = 120
end
if self.keys["left"].isDown then
self.xsp = -120 * dt
self.xsp = -120
end
if self.keys["right"].isDown then
self.xsp = 120 * dt
self.xsp = 120
end
Player.super.update(self, dt)

View file

@ -75,7 +75,7 @@ end
function Actor2D:update(dt)
self:autoMove()
self:autoMove(dt)
end
-- MOVEMENT FUNCTIONS
@ -88,8 +88,8 @@ function Actor2D:setFilter()
end
end
function Actor2D:autoMove()
self:move(self.x + self.xsp, self.y + self.ysp)
function Actor2D:autoMove(dt)
self:move(self.x + self.xsp * dt, self.y + self.ysp * dt)
end
function Actor2D:move(newx, newy)