2019-08-14 16:26:23 +02:00
|
|
|
local Parent = Object:extend() -- On créer la classe des entitées, c'est la classe de base
|
|
|
|
|
|
|
|
local maputils = require "scenes.battlesystem.utils"
|
|
|
|
|
2019-08-14 20:11:35 +02:00
|
|
|
-- INIT FUNCTION
|
|
|
|
-- Initilize the actor
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
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
|
|
|
|
|
2019-08-14 20:11:35 +02:00
|
|
|
function Parent:update(dt)
|
|
|
|
-- lol
|
|
|
|
end
|
|
|
|
|
|
|
|
-- SPRITE FUNCTIONS
|
|
|
|
-- Handle the character sprite
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
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
|
|
|
|
|
2019-08-14 20:11:35 +02:00
|
|
|
-- DRAW FUNCTIONS
|
|
|
|
-- Handle draw functions
|
2019-08-14 16:26:23 +02:00
|
|
|
|
|
|
|
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
|