2021-05-05 08:30:32 +02:00
|
|
|
local World3D = require "birb.modules.world.world3D"
|
2020-08-16 10:52:00 +02:00
|
|
|
local ParentWorld = World3D:extend()
|
2019-07-26 20:22:18 +02:00
|
|
|
|
2021-08-15 15:39:16 +02:00
|
|
|
local customMap = require "game.modules.subgames.world.maps"
|
2019-07-27 13:32:11 +02:00
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function ParentWorld:new(scene, maptype, mapname)
|
|
|
|
local mappath = game.utils.getMapPath("test", "test")
|
|
|
|
self.customMap = customMap
|
|
|
|
|
2021-08-15 15:39:16 +02:00
|
|
|
ParentWorld.super.new(self, scene, "game.modules.subgames.world.actors", mappath, maptype)
|
2019-07-27 15:11:14 +02:00
|
|
|
|
|
|
|
self.mapname = mapname
|
2020-08-16 10:52:00 +02:00
|
|
|
self.autorun = false
|
2019-07-26 20:22:18 +02:00
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function ParentWorld:createMapController()
|
|
|
|
customMap.Test(self)
|
2019-07-27 13:32:11 +02:00
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function ParentWorld:loadMapObjects()
|
|
|
|
ParentWorld.super.loadMapObjects(self)
|
2019-07-27 11:42:37 +02:00
|
|
|
self:addInvisibleWalls()
|
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function ParentWorld:newObjFromIndex(id, x, y, z)
|
|
|
|
self.obj.index[id](self, x, y, z)
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParentWorld:addInvisibleWalls()
|
2019-07-27 11:42:37 +02:00
|
|
|
local w, h = self:getDimensions()
|
|
|
|
self.obj.collisions["invisible"](self, 0, -16, 0, w, 16, 1000)
|
|
|
|
self.obj.collisions["invisible"](self, 0, h, 0, w, 16, 1000)
|
|
|
|
self.obj.collisions["invisible"](self, w, 0, 0, 16, h, 1000)
|
|
|
|
self.obj.collisions["invisible"](self, -16, 0, 0, 16, h, 1000)
|
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function ParentWorld:getViewCenter(x, y)
|
|
|
|
return x, y-16
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParentWorld:draw(dt)
|
2019-07-27 13:52:41 +02:00
|
|
|
self:drawBackgroundColor()
|
|
|
|
local camNumber = self.cameras:getViewNumber()
|
|
|
|
|
|
|
|
if (camNumber == 0) then
|
|
|
|
self:drawMap()
|
|
|
|
self:drawActors()
|
|
|
|
else
|
|
|
|
for i=1, camNumber do
|
|
|
|
self:drawParallax(i)
|
|
|
|
self.cameras:attachView(i)
|
|
|
|
self:drawMap(i)
|
|
|
|
self:drawActors(i)
|
|
|
|
self.cameras:detachView(i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
function ParentWorld:drawMap(i)
|
|
|
|
local x, y, w, h = self.cameras:getViewCoordinate(i)
|
|
|
|
if (self.map ~= nil) then
|
|
|
|
self.map:draw(x, y, w, h)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ParentWorld:drawParallax(i)
|
2019-07-27 13:52:41 +02:00
|
|
|
local x, y, w, h = self.cameras:getViewCoordinate(i)
|
|
|
|
if (self.map ~= nil) and (self.maptype ~= "sti") then
|
|
|
|
self.map:drawParallax(x, y, w, h)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-16 10:52:00 +02:00
|
|
|
return ParentWorld
|