sonic-bluestreak/sonic-bluestreak.love/game/modules/world/init.lua

66 lines
1.8 KiB
Lua
Raw Normal View History

2019-12-28 12:15:43 +01:00
local World3D = require "core.modules.world.world3D"
local RadianceWorld = World3D:extend()
local customMap = require "game.modules.world.maps"
function RadianceWorld:new(scene, maptype, mapname)
local mappath = game.utils.getMapPath(maptype, mapname)
RadianceWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
self.mapname = mapname
end
function RadianceWorld:createMapController()
if (self.maptype == "test") then
customMap.Test(self)
elseif (self.maptype == "battle") then
customMap.Battle(self, self.maptype, self.mapname)
elseif (self.maptype == "shoot") then
customMap.Shoot(self, self.maptype, self.mapname)
self.cameras:lockY(4)
else
RadianceWorld.super.createMapController(self)
end
end
function RadianceWorld:loadMapObjects()
RadianceWorld.super.loadMapObjects(self)
self:addInvisibleWalls()
end
function RadianceWorld:addInvisibleWalls()
local w, h = self:getDimensions()
print(w, h)
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
function RadianceWorld:draw(dt)
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
function RadianceWorld:drawParallax(i)
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
return RadianceWorld