feat: load map data from layout files

This commit is contained in:
Kazhnuz 2020-01-02 21:56:42 +01:00
parent 3bc2ea3e41
commit 4aeab15340
6 changed files with 38 additions and 31 deletions

View file

@ -0,0 +1,14 @@
return {
datas = {
zone = "forest",
bypass_zone = true,
bypass_data = {
tiles = 3,
background = nil
}
},
layout = {{"self", {00}}, {"basics", {00, 00}},},
parts = {
[0] = {{"basics", {01}}, {"basics", {00}}}
}
}

View file

@ -1,26 +0,0 @@
return {
datas = {
zone = "forest",
bypass_zone = false,
bypass_data = {
name = nil,
borders = 3,
tiles = 3,
background = nil,
music = nil
},
missiondata = {
leveltype = "loop",
missiontype = "goal",
turns = 4
}
},
layout = {{"self", {00}}, {"basics", {00, 00}},},
parts = {
[0] = {{"basics", {01}}, {"basics", {00}}}
},
endless_parts = {
{"basics", 00},
{"self", 00}
}
}

View file

@ -10,9 +10,28 @@ function ShootMap:new(world, maptype, mapname)
ShootMap.super.new(self, world) ShootMap.super.new(self, world)
self:setPadding(0, 0, 0, 0) self:setPadding(0, 0, 0, 0)
self.textureId = zoneDatas[mapname].tiles self:getLevelData(mapname)
self.background = zoneDatas[mapname].background self:generateTextures(self.datas.tiles, self.datas.background)
self:generateTextures(self.textureId, self.background) end
function ShootMap:getLevelData(mapname)
local file = file or "testlevel.test1"
local level = require("datas.gamedata.maps.shoot." .. file)
self.zone = level.datas.zone
local currentZone_datas = zoneDatas[self.zone]
local bypass_data = level.datas.bypass_data
self.datas = {}
if (level.datas.bypass_zone) then
self.datas.tiles = bypass_data.tiles or currentZone_datas.tiles
self.datas.background = bypass_data.background or currentZone_datas.background
else
self.datas = currentZone_datas
end
end end
function ShootMap:loadCollisions() function ShootMap:loadCollisions()

View file

@ -33,9 +33,9 @@ function MovePlayer:new()
end end
function MovePlayer:initWorld() function MovePlayer:initWorld()
--ShootWorld(self, "coast") ShootWorld(self, "testlevel.test1")
--BattleWorld(self, "ebeach") --BattleWorld(self, "ebeach")
TestWorld(self) --TestWorld(self)
end end
return MovePlayer return MovePlayer