modules/world: make speed relative to dt
This commit is contained in:
parent
93f710e0b0
commit
a25e178628
2 changed files with 7 additions and 7 deletions
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue