modules/world: refactor movement functions together
This commit is contained in:
parent
4b4b8b4e85
commit
11fcc4cf99
1 changed files with 9 additions and 6 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue