2021-11-25 11:28:31 +01:00
|
|
|
local Base = require "birb.modules.world.actors.actor3D"
|
2019-12-28 12:15:43 +01:00
|
|
|
local Parent = Base:extend()
|
|
|
|
|
|
|
|
function Parent:new(world, type, x, y, z, w, h, d, isSolid)
|
|
|
|
self.scene = world.scene
|
|
|
|
Parent.super.new(self, world, type, x, y, z, w, h, d, isSolid)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Parent:draw()
|
2019-12-28 15:18:14 +01:00
|
|
|
self:drawStart()
|
|
|
|
if (self.box ~= nil) then
|
2021-11-27 13:10:37 +01:00
|
|
|
self.box:draw(math.floor(self.x), math.floor(self.y), math.floor(self.z))
|
2019-12-28 15:18:14 +01:00
|
|
|
else
|
2021-11-27 13:10:37 +01:00
|
|
|
local x, y, z = self:computeDrawingPosition()
|
|
|
|
if (math.floor(z) < -2) and (self.world.maptype == "shoot") then
|
|
|
|
core.screen:setScissor(0, 0, 424, 58+self.y/2)
|
2020-01-12 00:02:06 +01:00
|
|
|
self:drawSprite(x, y)
|
|
|
|
core.screen:resetScissor()
|
|
|
|
else
|
|
|
|
self:drawSprite(x, y)
|
|
|
|
end
|
2019-12-28 15:18:14 +01:00
|
|
|
end
|
|
|
|
self:drawEnd()
|
2019-12-28 12:15:43 +01:00
|
|
|
end
|
|
|
|
|
2021-11-27 13:10:37 +01:00
|
|
|
function Parent:computeDrawingPosition()
|
|
|
|
local drawx, drawy, drawz = self.x, self.y, self.z
|
|
|
|
if (self.world.maptype == "shoot") then
|
|
|
|
drawx = drawx + math.floor(drawy/2)
|
|
|
|
end
|
|
|
|
return math.floor(drawx), math.floor(drawy - drawz - self.d + (self.h/2)), math.floor(drawz)
|
|
|
|
end
|
|
|
|
|
2019-12-28 12:15:43 +01:00
|
|
|
function Parent:drawShadow(x, y)
|
2019-12-28 16:54:13 +01:00
|
|
|
local x = x or 0
|
|
|
|
local y = y or 0
|
2019-12-28 15:18:14 +01:00
|
|
|
if (self.world.maptype == "shoot") then
|
|
|
|
x = x + math.floor(y/2)
|
|
|
|
end
|
2019-12-28 12:15:43 +01:00
|
|
|
self.assets.images["shadow"]:draw(x-4, y+4)
|
|
|
|
end
|
|
|
|
|
|
|
|
return Parent
|