From d2ba9f3c87589f167e715b17f6740977e1c29dff Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 3 Sep 2017 01:55:35 +0200 Subject: More map config and loading changes Decorations, platforms and background are now created and stored in config together --- not/World.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'not/World.lua') diff --git a/not/World.lua b/not/World.lua index d4d933f..8a6ba09 100644 --- a/not/World.lua +++ b/not/World.lua @@ -47,21 +47,23 @@ end -- Load map from file -- TODO: Change current map model to function-based one. function World:loadMap (name) - local name = name or "default" - local map = love.filesystem.load(string.format("config/maps/%s.lua", name)) - self.map = map() - -- Platforms - for _,platform in pairs(self.map.platforms) do - local config = love.filesystem.load(string.format("config/platforms/%s.lua", platform.config))() - self:createPlatform(platform.x, platform.y, config.shape, config.sprite, platform.animations) - end - -- Decorations - for _,decoration in pairs(self.map.decorations) do - self:createDecoration(decoration.x, decoration.y, decoration.sprite) + local map = string.format("config/maps/%s.lua", name or "default") + self.map = love.filesystem.load(map)() + + for _,op in pairs(self.map.create) do + if op.platform then + local path = string.format("config/platforms/%s.lua", op.platform) + local config = love.filesystem.load(path)() + self:createPlatform(op.x, op.y, config.shape, config.sprite, config.animations) + end + if op.decoration then + self:createDecoration(op.x, op.y, op.decoration) + end + if op.background then + self.background = love.graphics.newImage(op.background) + end end - -- Background - self.background = love.graphics.newImage(self.map.background) - -- Clouds + if self.map.clouds then for i=1,6 do self:randomizeCloud(false) -- cgit v1.1