summaryrefslogtreecommitdiffhomepage
path: root/world.lua
diff options
context:
space:
mode:
Diffstat (limited to 'world.lua')
-rw-r--r--world.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/world.lua b/world.lua
index c11855d..d1f1a3e 100644
--- a/world.lua
+++ b/world.lua
@@ -7,6 +7,7 @@ require "ground"
require "player"
require "cloud"
require "effect"
+require "decoration"
-- Metatable of `World`
-- nils initialized in constructor
@@ -16,8 +17,8 @@ World = {
Nauts = nil,
Platforms = nil,
Clouds = nil,
- EffectsBottom = nil,
- EffectsTop = nil,
+ Decorations = nil,
+ Effects = nil,
camera = nil,
-- cloud generator
clouds_delay = 6,
@@ -45,6 +46,8 @@ function World:new(map, ...)
o.Clouds = c
local e = {}
o.Effects = e
+ local d = {}
+ o.Decorations = d
-- Random init
math.randomseed(os.time())
-- Map
@@ -71,6 +74,9 @@ function World:loadMap(name)
for _,platform in pairs(self.map.platforms) do
self:createPlatform(platform.x, platform.y, platform.shape, platform.sprite)
end
+ for _,decoration in pairs(self.map.decorations) do
+ self:createDecoration(decoration.x, decoration.y, decoration.sprite)
+ end
end
-- Spawn all the nauts for the round
@@ -107,6 +113,11 @@ function World:createNaut(x, y, name)
return naut
end
+-- Add new decoration to the world
+function World:createDecoration(x, y, sprite)
+ table.insert(self.Decorations, Decoration:new(x, y, sprite))
+end
+
-- Add new cloud to the world
function World:createCloud(x, y, t, v)
table.insert(self.Clouds, Cloud:new(x, y, t, v))
@@ -190,6 +201,11 @@ function World:draw()
cloud:draw(offset_x, offset_y, scale)
end
+ -- Draw decorations
+ for _,decoration in pairs(self.Decorations) do
+ decoration:draw(offset_x, offset_y, scale)
+ end
+
-- Draw effects
for _,effect in pairs(self.Effects) do
effect:draw(offset_x,offset_y, scale)