modules/world: refactor movement functions together

This commit is contained in:
Kazhnuz 2019-05-05 21:25:25 +02:00
parent 4b4b8b4e85
commit 11fcc4cf99

View file

@ -38,12 +38,7 @@ end
function Actor2D:initPhysics(x, y, w, h, isSolid) function Actor2D:initPhysics(x, y, w, h, isSolid)
self:initHitbox(x, y, w, h) self:initHitbox(x, y, w, h)
self.xsp = 0 self:initMovement()
self.ysp = 0
self.xfrc = 0
self.yfrc = 0
self:setBounceFactor() self:setBounceFactor()
self:initGravity() self:initGravity()
@ -70,6 +65,14 @@ function Actor2D:setFilter()
end end
end end
function Actor2D:initMovement()
self.xsp = 0
self.ysp = 0
self.xfrc = 0
self.yfrc = 0
end
function Actor2D:autoMove(dt) function Actor2D:autoMove(dt)
self.onGround = false self.onGround = false
self:applyGravity(dt) self:applyGravity(dt)