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) function Player:update(dt)
self.xsp, self.ysp = 0, 0 self.xsp, self.ysp = 0, 0
if self.keys["up"].isDown then if self.keys["up"].isDown then
self.ysp = -120 * dt self.ysp = -120
end end
if self.keys["down"].isDown then if self.keys["down"].isDown then
self.ysp = 120 * dt self.ysp = 120
end end
if self.keys["left"].isDown then if self.keys["left"].isDown then
self.xsp = -120 * dt self.xsp = -120
end end
if self.keys["right"].isDown then if self.keys["right"].isDown then
self.xsp = 120 * dt self.xsp = 120
end end
Player.super.update(self, dt) Player.super.update(self, dt)

View file

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