sonic-radiance/sonic-radiance.love/scenes/battlesystem/entities/base.lua

61 lines
1.4 KiB
Lua

local BaseEntity = Object:extend() -- On créer la classe des entitées, c'est la classe de base
function BaseEntity:new(controller, x, y, z)
self.depth = 0
self.x = x
self.y = y
self.z = z or 0
self.direction = 1
--self.id = self.world.creationID
self.controller = controller
self.assets = self.controller.assets
self.isHero = false
self.isActor = false
self.isEnnemy = false
self:register()
end
function BaseEntity:register()
self.controller.battlearena:registerEntity(self)
self.id = self.controller.battlearena.globalID
end
function BaseEntity:setSprite(name, ox, oy, active)
self.sprite = {}
self.sprite.name = name
self.sprite.ox = ox or 0
self.sprite.oy = oy or 0
self.sprite.active = active or false
end
function BaseEntity:drawSprite(tx, ty)
utils.draw.resetColor()
local x, y = self.controller.battlearena:gridToPixel(self.x, self.y, true)
local tx = tx or 0
local ty = ty or 0
if (self.sprite.active) then
self.assets.sprites[self.sprite.name]:drawAnimation(x + tx, y + ty, 0, self.direction, 1, self.sprite.ox, self.sprite.oy)
end
end
function BaseEntity:update(dt)
-- lol
end
function BaseEntity:draw()
end
function BaseEntity:drawShadow()
local x, y = self.controller.battlearena:gridToPixel(self.x, self.y, true)
love.graphics.draw(self.controller.battlearena.textures.shadow, x, y, 0, 1, 1, 12, 5)
end
return BaseEntity