summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-03 01:55:35 +0200
committerAki <nthirtyone@gmail.com>2017-09-03 01:55:35 +0200
commitd2ba9f3c87589f167e715b17f6740977e1c29dff (patch)
tree9b0c8f14bdcd80cce1fb04ce8d01c23f2801ed92
parent2757fa1de92f2eff8be080721a7f777086afa072 (diff)
downloadroflnauts-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
-rw-r--r--config/maps/ribbit.lua18
-rw-r--r--config/maps/starstorm.lua35
-rw-r--r--not/World.lua30
3 files changed, 44 insertions, 39 deletions
diff --git a/config/maps/ribbit.lua b/config/maps/ribbit.lua
index 48e84c8..40ae355 100644
--- a/config/maps/ribbit.lua
+++ b/config/maps/ribbit.lua
@@ -13,28 +13,30 @@ return
{x = 15, y = -80}
},
clouds = false,
- background = "assets/backgrounds/ribbit.png",
- platforms = {
+ create = {
+ {
+ ratio = 0,
+ background = "assets/backgrounds/ribbit.png"
+ },
{
x = -154,
y = 10,
- config = "ribbit-left"
+ platform = "ribbit-left"
},
{
x = 67,
y = 7,
- config = "ribbit-right"
+ platform = "ribbit-right"
},
{
x = -70,
y = -5,
- config = "ribbit-top"
+ platform = "ribbit-top"
},
{
x = -54,
y = 63,
- config = "ribbit-bottom"
+ platform = "ribbit-bottom"
}
- },
- decorations = {}
+ }
}
diff --git a/config/maps/starstorm.lua b/config/maps/starstorm.lua
index fe45e04..eaf488e 100644
--- a/config/maps/starstorm.lua
+++ b/config/maps/starstorm.lua
@@ -15,64 +15,65 @@ return
{x = 110, y = -70}
},
clouds = false,
- background = "assets/backgrounds/starstorm.png",
- platforms = {
+ create = {
+ {
+ ratio = 0,
+ background = "assets/backgrounds/starstorm.png"
+ },
{
x = -170,
y = -55,
- config = "starstorm-left-top"
+ platform = "starstorm-left-top"
},
{
x = -156,
y = -2,
- config = "starstorm-left-middle"
+ platform = "starstorm-left-middle"
},
{
x = -160,
y = 69,
- config = "starstorm-left-bottom"
+ platform = "starstorm-left-bottom"
},
{
x = 52,
y = -55,
- config = "starstorm-right-top"
+ platform = "starstorm-right-top"
},
{
x = 44,
y = -2,
- config = "starstorm-right-middle"
+ platform = "starstorm-right-middle"
},
{
x = 55,
y = 69,
- config = "starstorm-right-bottom"
+ platform = "starstorm-right-bottom"
},
{
x = -27,
y = 40,
- config = "starstorm-center"
- }
- },
- decorations = {
+ platform = "starstorm-center"
+ },
{
x = -166,
y = -37,
- sprite = "assets/decorations/starstorm-left-top.png"
+ decoration = "assets/decorations/starstorm-left-top.png"
},
{
x = -163,
y = 19,
- sprite = "assets/decorations/starstorm-left-bottom.png"
+ decoration = "assets/decorations/starstorm-left-bottom.png"
},
{
x = 119,
y = -37,
- sprite = "assets/decorations/starstorm-right-top.png"
+ decoration = "assets/decorations/starstorm-right-top.png"
},
{
- x = 52+77,
+ x = 129,
y = 19,
- sprite = "assets/decorations/starstorm-right-bottom.png"
+ decoration = "assets/decorations/starstorm-right-bottom.png"
}
}
}
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)