From 11fcc4cf99eed48cae254317afce6e058ed92e77 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 5 May 2019 21:25:25 +0200 Subject: [PATCH] modules/world: refactor movement functions together --- gamecore/modules/world/actors/actor2D.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index ca4f2b4..ac56c26 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -38,12 +38,7 @@ end function Actor2D:initPhysics(x, y, w, h, isSolid) self:initHitbox(x, y, w, h) - self.xsp = 0 - self.ysp = 0 - - self.xfrc = 0 - self.yfrc = 0 - + self:initMovement() self:setBounceFactor() self:initGravity() @@ -70,6 +65,14 @@ function Actor2D:setFilter() end end +function Actor2D:initMovement() + self.xsp = 0 + self.ysp = 0 + + self.xfrc = 0 + self.yfrc = 0 +end + function Actor2D:autoMove(dt) self.onGround = false self:applyGravity(dt)