diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 1838669..a201ea4 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -98,19 +98,6 @@ function Actor2D:changeSpeedToCollisionNormal(nx, ny) self.xsp, self.ysp = xsp, ysp end -function Actor2D:checkGround() - local dx, dy = self.x, self.y + utils.math.sign(self.grav) - local newx, newy, cols, colNumber = self:checkCollision(dx, dy) - - for i, col in ipairs(cols) do - if (col.type == "touch") or (col.type == "bounce") or (col.type == "slide") then - if not (self.grav == 0) then - if col.normal.y ~= utils.math.sign(self.grav) then self.onGround = true end - end - end - end -end - function Actor2D:move(dx, dy) local cols, colNumber = {}, 0 if (self.isDestroyed == false) then @@ -138,6 +125,9 @@ function Actor2D:initGravity() 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 @@ -154,6 +144,19 @@ function Actor2D:applyGravity(dt) end end +function Actor2D:checkGround() + local dx, dy = self.x, self.y + utils.math.sign(self.grav) + local newx, newy, cols, colNumber = self:checkCollision(dx, dy) + + for i, col in ipairs(cols) do + if (col.type == "touch") or (col.type == "bounce") or (col.type == "slide") then + if not (self.grav == 0) then + if col.normal.y ~= utils.math.sign(self.grav) then self.onGround = true end + end + end + end +end + -- HITBOXES FUNCTIONS -- Functions related to actor hitboxes