From 93ce28f3ba7c03b4a2140af33c705bdd90bfaaa9 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 1 Feb 2020 16:44:38 +0100 Subject: [PATCH] fix: simplify shadows handling --- .../world/actors/collisions/fakefloor.lua | 29 +++++++++++++++++++ .../game/modules/world/actors/init.lua | 1 + .../game/modules/world/maps/shoot.lua | 3 ++ .../game/modules/world/maps/tools/chunk.lua | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 sonic-bluestreak.love/game/modules/world/actors/collisions/fakefloor.lua diff --git a/sonic-bluestreak.love/game/modules/world/actors/collisions/fakefloor.lua b/sonic-bluestreak.love/game/modules/world/actors/collisions/fakefloor.lua new file mode 100644 index 0000000..49f2402 --- /dev/null +++ b/sonic-bluestreak.love/game/modules/world/actors/collisions/fakefloor.lua @@ -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 diff --git a/sonic-bluestreak.love/game/modules/world/actors/init.lua b/sonic-bluestreak.love/game/modules/world/actors/init.lua index a373d68..fea28f9 100644 --- a/sonic-bluestreak.love/game/modules/world/actors/init.lua +++ b/sonic-bluestreak.love/game/modules/world/actors/init.lua @@ -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 diff --git a/sonic-bluestreak.love/game/modules/world/maps/shoot.lua b/sonic-bluestreak.love/game/modules/world/maps/shoot.lua index 47cace4..e05d1f4 100644 --- a/sonic-bluestreak.love/game/modules/world/maps/shoot.lua +++ b/sonic-bluestreak.love/game/modules/world/maps/shoot.lua @@ -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() diff --git a/sonic-bluestreak.love/game/modules/world/maps/tools/chunk.lua b/sonic-bluestreak.love/game/modules/world/maps/tools/chunk.lua index 076d1f8..a254eef 100644 --- a/sonic-bluestreak.love/game/modules/world/maps/tools/chunk.lua +++ b/sonic-bluestreak.love/game/modules/world/maps/tools/chunk.lua @@ -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