diff options
author | Aki <nthirtyone@gmail.com> | 2016-06-03 00:55:56 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-06-03 00:55:56 +0200 |
commit | 1027ec0d527d29c5ae47919ae12bcab176b46182 (patch) | |
tree | 57c76cb5c3fbcba05ed72bdcdd07fe18ed2b93ad /world.lua | |
parent | 728c8aa62add0310119017615c7e973e35daf146 (diff) | |
download | roflnauts-1027ec0d527d29c5ae47919ae12bcab176b46182.zip roflnauts-1027ec0d527d29c5ae47919ae12bcab176b46182.tar.gz roflnauts-1027ec0d527d29c5ae47919ae12bcab176b46182.tar.bz2 |
Map decorations added
Diffstat (limited to 'world.lua')
-rw-r--r-- | world.lua | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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) |