fix: simplify shadows handling

This commit is contained in:
Kazhnuz 2020-02-01 16:44:38 +01:00
parent 89c5940116
commit 93ce28f3ba
4 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,29 @@
local Base = require "core.modules.world.actors.actor3D"
local FakeFloor = Base:extend()
function FakeFloor:new(world, x, y, z, w, h, d)
FakeFloor.super.new(self, world, "fakefloor", x, y, z, w, h, d, false)
self:setDebugColor(0,0,0)
self.boxes.Base(self, w, h, d, false)
end
function FakeFloor:update(dt)
end
function FakeFloor:draw()
local drawx, drawy, drawz = self.x, self.y, self.z
if (self.world.maptype == "shoot") then
drawx = drawx + math.floor(drawy/2)
end
self:drawStart()
if (self.box ~= nil) then
self.box:draw(drawx, drawy, drawz)
else
local x, y = math.floor(drawx), math.floor(drawy - drawz - self.d + (self.h/2))
self:drawSprite(x, y)
end
self:drawEnd()
end
return FakeFloor

View file

@ -13,6 +13,7 @@ Obj.collisions["wall"] = require(cwd .. "collisions.wall")
Obj.collisions["invisible"] = require(cwd .. "collisions.invisible")
Obj.collisions["floor"] = require(cwd .. "collisions.floor")
Obj.collisions["textured"] = require(cwd .. "collisions.textured")
Obj.collisions["fakefloor"] = require(cwd .. "collisions.fakefloor")
Obj.index = {}
Obj.index[01] = Obj.Ring

View file

@ -56,6 +56,9 @@ function ShootMap:loadCollisions()
self.chunklist[chunkname]:spawnGrounds((i-1)*31*8)
self.chunklist[chunkname]:spawnObjects((i-1)*31*8)
end
local CHUNKSIZE = TILESIZE*8
self.world:newCollision("fakefloor", -CHUNKSIZE, 0, -48, self.width+CHUNKSIZE*2, 200, 48)
end
function ShootMap:loadLayout()

View file

@ -46,7 +46,7 @@ function Chunk:generateGround(basex)
for i, ground in ipairs(self.grounds) do
local x, y = ground.x, ground.y
local w, h = ground.w, ground.h
self.map.world:newCollision("floor", basex+(x-1)*31, (y-1)*20, -48, 31*w, 20*h, 48)
self.map.world:newCollision("invisible", basex+(x-1)*31, (y-1)*20, -48, 31*w, 20*h, 48)
end
end