diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 0427935..37c0c38 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -117,27 +117,9 @@ function Actor2D:checkCollision(dx, dy) return self.x, self.y, cols, colNumber end -function Actor2D:initGravity() - if (self.world.gravity.isDefault) then - self.grav = self.world.gravity.grav - else - self.grav = 0 - end - - self.onGround = false -end - -- GRAVITY SYSTEM FUNCTIONS -- All functions related to gravity -function Actor2D:setGravity(grav) - -- It's basically now a function with two roles at once : - -- - activate the gravity - -- - use the gravity value the dev want - - self.grav = grav or self.world.gravity.grav -end - function Actor2D:applyGravity(dt) self.ysp = self.ysp + self.grav * dt diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index 7a1269b..61b7827 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -132,6 +132,35 @@ function BaseActor:getViewCenter() return self:getCenter() end +-- GRAVITY SYSTEM FUNCTIONS +-- All functions related to gravity + +function BaseActor:initGravity() + if (self.world.gravity.isDefault) then + self.grav = self.world.gravity.grav + else + self.grav = 0 + end + + self.onGround = false +end + +function BaseActor:setGravity(grav) + -- It's basically now a function with two roles at once : + -- - activate the gravity + -- - use the gravity value the dev want + + self.grav = grav or self.world.gravity.grav +end + +function BaseActor:applyGravity(dt) + -- Empty function in baseactor +end + +function BaseActor:checkGround() + -- Empty function in baseactor +end + -- UPDATE FUNCTIONS -- Theses functions are activated every steps