local Base = require "core.modules.world.actors.actor2D" local Parent = Base:extend() function Parent:new(world, type, x, y, w, h, isSolid) self.scene = world.scene Parent.super.new(self, world, type, x, y, w, h, isSolid) self:initCharset() self.drawDebugBox = false end function Parent:update(dt) self.depth = -self.y Parent.super.update(self, dt) self.depth = -self.y end function Parent:isMoving() return ((math.abs(self.ysp) > 0.01) or (math.abs(self.xsp) > 0.01)) end -- Charset / Draw functions -- Handle the charset of an object function Parent:initCharset() self.charsetManager = self.world.scene.charsetManager self.charset = nil self.charDir = "down" self.cantWalk = false end function Parent:setCharset(charset, charId, cantWalk) self.charset = charset self.charId = charId self.cantWalk = (cantWalk == true) end function Parent:drawCharset(charset, charId) if (self:isMoving() and (not self.cantWalk)) then self.charsetManager:draw(self.charset, self.charId, self.charDir, self.x, self.y) else self.charsetManager:drawStanding(self.charset, self.charId, self.charDir, self.x, self.y) end end function Parent:draw() if (self.charset ~= nil) then self:drawCharset() end if (self.drawDebugBox) then love.graphics.rectangle("line", math.floor(self.x), math.floor(self.y), self.w, self.h) end end return Parent