chore: separate world types

This commit is contained in:
Kazhnuz 2019-12-28 14:13:19 +01:00
parent 294d2699e7
commit 9b16ae4429
4 changed files with 55 additions and 23 deletions

View file

@ -0,0 +1,17 @@
local ParentWorld = require "game.modules.world.parent"
local BattleWorld = ParentWorld:extend()
local customMap = require "game.modules.world.maps"
function BattleWorld:new(scene, mapname)
local mappath = game.utils.getMapPath("battle", mapname)
BattleWorld.super.new(self, scene, "battle", mapname)
self.mapname = mapname
end
function BattleWorld:createMapController()
customMap.Battle(self, self.maptype, self.mapname)
end
return BattleWorld

View file

@ -1,34 +1,27 @@
local World3D = require "core.modules.world.world3D"
local RadianceWorld = World3D:extend()
local ParentWorld = 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)
function ParentWorld:new(scene, maptype, mapname)
local mappath = game.utils.getMapPath("test", "test")
self.customMap = customMap
ParentWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
self.mapname = mapname
end
function RadianceWorld:createMapController()
if (self.maptype == "test") then
function ParentWorld:createMapController()
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(10)
else
RadianceWorld.super.createMapController(self)
end
end
function RadianceWorld:loadMapObjects()
RadianceWorld.super.loadMapObjects(self)
function ParentWorld:loadMapObjects()
ParentWorld.super.loadMapObjects(self)
self:addInvisibleWalls()
end
function RadianceWorld:addInvisibleWalls()
function ParentWorld:addInvisibleWalls()
local w, h = self:getDimensions()
print(w, h)
self.obj.collisions["invisible"](self, 0, -16, 0, w, 16, 1000)
@ -37,7 +30,7 @@ function RadianceWorld:addInvisibleWalls()
self.obj.collisions["invisible"](self, -16, 0, 0, 16, h, 1000)
end
function RadianceWorld:draw(dt)
function ParentWorld:draw(dt)
self:drawBackgroundColor()
local camNumber = self.cameras:getViewNumber()
@ -55,11 +48,11 @@ function RadianceWorld:draw(dt)
end
end
function RadianceWorld:drawParallax(i)
function ParentWorld: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
return ParentWorld

View file

@ -0,0 +1,18 @@
local ParentWorld = require "game.modules.world.parent"
local ShootWorld = ParentWorld:extend()
local customMap = require "game.modules.world.maps"
function ShootWorld:new(scene, mapname)
local mappath = game.utils.getMapPath("shoot", mapname)
ShootWorld.super.new(self, scene, "shoot", mapname)
self.mapname = mapname
end
function ShootWorld:createMapController()
self.customMap.Shoot(self, self.maptype, self.mapname)
self.cameras:lockY(10)
end
return ShootWorld

View file

@ -24,7 +24,9 @@
local Scene = require "core.modules.scenes"
local MovePlayer = Scene:extend()
local World = require "game.modules.world"
local TestWorld = require "game.modules.world.parent"
local ShootWorld = require "game.modules.world.shoot"
local BattleWorld = require "game.modules.world.battle"
function MovePlayer:new(playerNumber, cameraMode)
local playerNumber = playerNumber or 1
@ -33,7 +35,9 @@ function MovePlayer:new(playerNumber, cameraMode)
MovePlayer.super.new(self)
self.assets:batchImport("scenes.test_scene.assets")
World(self, "shoot", "coast")
--ShootWorld(self, "coast")
--BattleWorld(self, "ebeach")
TestWorld(self)
self.world:setPlayerNumber(playerNumber)
self.world.cameras:setMode(cameraMode)