refactor(levels): remove all functions already provided by Actor2D
This commit is contained in:
parent
666aa13565
commit
4ee17f01b6
|
@ -1,4 +1,5 @@
|
||||||
local Entity = Object:extend() -- On créer la classe des entitées, c'est la classe de base
|
local Base = require "core.modules.world.actors.actor2D"
|
||||||
|
local Entity = Base:extend() -- On créer la classe des entitées, c'est la classe de base
|
||||||
|
|
||||||
function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entité, avec par défaut sa hitbox.
|
function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entité, avec par défaut sa hitbox.
|
||||||
self:initPhysics(world, type, x, y, w, h)
|
self:initPhysics(world, type, x, y, w, h)
|
||||||
|
@ -8,10 +9,8 @@ function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entit
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:initPhysics(world, type, x, y, w, h)
|
function Entity:initPhysics(world, type, x, y, w, h)
|
||||||
self.scene = world.scene
|
self:setManagers(world)
|
||||||
self.world = world
|
|
||||||
self.camera = self.scene.camera
|
self.camera = self.scene.camera
|
||||||
self.obj = self.world.obj
|
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
self.gacc = 550
|
self.gacc = 550
|
||||||
|
@ -22,10 +21,7 @@ function Entity:initPhysics(world, type, x, y, w, h)
|
||||||
self.grav = 0
|
self.grav = 0
|
||||||
self.frc = 0
|
self.frc = 0
|
||||||
|
|
||||||
self.x = x or 0
|
self:initHitbox(x, y, w, h)
|
||||||
self.y = y or 0
|
|
||||||
self.w = w or 16
|
|
||||||
self.h = h or 16
|
|
||||||
self.onGround = false
|
self.onGround = false
|
||||||
|
|
||||||
self.playerID = -1
|
self.playerID = -1
|
||||||
|
@ -33,25 +29,10 @@ function Entity:initPhysics(world, type, x, y, w, h)
|
||||||
self:register()
|
self:register()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:setDebugColor(r,g,b)
|
|
||||||
self.debug = {}
|
|
||||||
self.debug.r = r
|
|
||||||
self.debug.g = r
|
|
||||||
self.debug.b = r
|
|
||||||
end
|
|
||||||
|
|
||||||
function Entity:update(dt)
|
function Entity:update(dt)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:register()
|
|
||||||
self.world:registerActor(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Entity:destroy()
|
|
||||||
self.world:removeActor(self)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Entity:canBounce(bounce)
|
function Entity:canBounce(bounce)
|
||||||
self.bounce = bounce
|
self.bounce = bounce
|
||||||
end
|
end
|
||||||
|
@ -99,21 +80,10 @@ function Entity:changeSpeedToCollisionNormal(nx, ny)
|
||||||
self.xsp, self.ysp = xsp, ysp
|
self.xsp, self.ysp = xsp, ysp
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:getCenter()
|
|
||||||
return self.x + self.w / 2,
|
|
||||||
self.y + self.h / 2
|
|
||||||
end
|
|
||||||
|
|
||||||
function Entity:purge()
|
function Entity:purge()
|
||||||
self:remove()
|
self:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:setFilter()
|
|
||||||
self.filter = function(item, other)
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Entity:checkGround(ny)
|
function Entity:checkGround(ny)
|
||||||
if not (self.grav == 0) then
|
if not (self.grav == 0) then
|
||||||
if ny < 0 then self.onGround = true end
|
if ny < 0 then self.onGround = true end
|
||||||
|
|
Loading…
Reference in New Issue