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 self.cantTurn = false self.isTurning = false self.isFast = false end function Parent:setCharset(charset, charId, cantWalk) self.charset = charset self.charId = charId self.cantWalk = (cantWalk == true) end function Parent:drawCharset(charset, charId) local x, y = utils.math.floorCoord(self.x, self.y) y = y - 2 local z = math.floor(self.z) love.graphics.setColor(1,1,1,0.5) self.assets.images["shadow"]:draw(x + 1, y + 11) utils.graphics.resetColor() if (not self.isTurning) then if (self:isMoving() and (not self.cantWalk)) then self.charsetManager:draw(self.charset, self.charId, self.charDir, x, y - z, self.isFast) else self.charsetManager:drawStanding(self.charset, self.charId, self.charDir, x, y - z, self.isFast) end else self.charsetManager:drawTurning(self.charset, self.charId, x, y - z, self.isFast) end end function Parent:draw() if (self.charset ~= nil) then self:drawCharset() else if (self.drawDebugBox) then love.graphics.rectangle("line", math.floor(self.x), math.floor(self.y), self.w, self.h) end end end return Parent