diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 2f16d3a..ed20ae8 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -36,32 +36,9 @@ function Actor2D:new(world, type, x, y, w, h, isSolid) self:register() end -function Actor2D:initPhysics() - self:initMovement() - self:setBounceFactor() - self:initGravity() - - self:setFilter() -end - -function Actor2D:setBounceFactor(newBounceFactor) - self.bounceFactor = newBounceFactor or 0 -end - -- MOVEMENT FUNCTIONS -- Basic functions from the movement. -function Actor2D:setFilter() - -- Init the bump filter - self.filter = function(item, other) - if (other.isSolid) then - return "slide" - else - return "cross" - end - end -end - function Actor2D:initMovement() self.xsp = 0 self.ysp = 0 diff --git a/gamecore/modules/world/actors/baseactor.lua b/gamecore/modules/world/actors/baseactor.lua index a513ed7..d6e2b2e 100644 --- a/gamecore/modules/world/actors/baseactor.lua +++ b/gamecore/modules/world/actors/baseactor.lua @@ -66,6 +66,41 @@ function BaseActor:destroy() self.isDestroyed = true end +-- PHYSICS INITIALISATION +-- Basic initialization of the physic systems + +function BaseActor:initPhysics() + self:initMovement() + self:initGravity() + + self:setBounceFactor() + self:setFilter() +end + +function BaseActor:setBounceFactor(newBounceFactor) + self.bounceFactor = newBounceFactor or 0 +end + +function BaseActor:setFilter() + -- Init the bump filter + self.filter = function(item, other) + if (other.isSolid) then + return "slide" + else + return "cross" + end + end +end + +function BaseActor:initMovement( ) + -- Empty placeholder function +end + +function BaseActor:initGravity( ) + -- Empty placeholder function +end + + -- UPDATE FUNCTIONS -- Theses functions are activated every steps