diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-03 01:55:35 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-03 01:55:35 +0200 |
commit | d2ba9f3c87589f167e715b17f6740977e1c29dff (patch) | |
tree | 9b0c8f14bdcd80cce1fb04ce8d01c23f2801ed92 /not/World.lua | |
parent | 2757fa1de92f2eff8be080721a7f777086afa072 (diff) | |
download | roflnauts-d2ba9f3c87589f167e715b17f6740977e1c29dff.zip roflnauts-d2ba9f3c87589f167e715b17f6740977e1c29dff.tar.gz roflnauts-d2ba9f3c87589f167e715b17f6740977e1c29dff.tar.bz2 |
More map config and loading changes
Decorations, platforms and background are now created and stored in config together
Diffstat (limited to 'not/World.lua')
-rw-r--r-- | not/World.lua | 30 |
1 files changed, 16 insertions, 14 deletions
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) |