sonic-radiance/sonic-radiance.love/scenes/battlesystem/actors/parent.lua

71 lines
1.4 KiB
Lua
Raw Normal View History

local Parent = Object:extend() -- On créer la classe des entitées, c'est la classe de base
local maputils = require "scenes.battlesystem.utils"
function Parent:new(world, 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.world = world
self.assets = self.world.assets
self.scene = self.world.scene
self.map = self.world.map
self.maputils = maputils
self.isHero = false
self.isActor = false
self.isEnnemy = false
self:register()
end
function Parent:register()
self.world:registerActor(self)
end
function Parent: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 Parent:drawSprite(tx, ty)
utils.graphics.resetColor()
local x, y = self.maputils.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 Parent:update(dt)
-- lol
end
function Parent:draw()
end
function Parent:drawShadow()
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
self.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
end
function Parent:drawHUD()
end
return Parent