summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-13 01:42:33 +0200
committerAki <nthirtyone@gmail.com>2017-09-13 01:42:33 +0200
commit6b9942d1f9a4ac58d92d16a0db13a09c9488df71 (patch)
treeec66ee467d7aca1c61053d1067b1155076ac4ae1
parentddf8c5f880e7175ce316e61471743654b2486d14 (diff)
downloadroflnauts-6b9942d1f9a4ac58d92d16a0db13a09c9488df71.zip
roflnauts-6b9942d1f9a4ac58d92d16a0db13a09c9488df71.tar.gz
roflnauts-6b9942d1f9a4ac58d92d16a0db13a09c9488df71.tar.bz2
Layers initialization moved to separate method
-rw-r--r--not/World.lua38
1 files changed, 20 insertions, 18 deletions
diff --git a/not/World.lua b/not/World.lua
index e75880f..529af2a 100644
--- a/not/World.lua
+++ b/not/World.lua
@@ -19,24 +19,10 @@ function World:new (map, nauts)
self.world:setCallbacks(self:getContactCallbacks())
self.lastNaut = false
-
- -- TODO: Clean layering. This is prototype. Seriously don't use it in production.
self.entities = {}
- local width, height = love.graphics.getDimensions()
- self.layers = {}
- for i=1,6 do
- table.insert(self.layers, Layer(width, height))
- end
- self.layers[1].ratio = 0
- -- TODO: Scaled layers for Rays and future extensions.
- do
- local layer = Layer(320, 180)
- layer.ratio = 0
- layer.scale = 1
- table.insert(self.layers, layer) -- 7
- end
-
self.map = map
+
+ self:initLayers()
self:buildMap()
self:initClouds()
self:spawnNauts(nauts)
@@ -58,6 +44,23 @@ function World:delete ()
collectgarbage()
end
+-- TODO: Clean layering. This isn't for stable release, yet.
+function World:initLayers ()
+ local width, height = love.graphics.getDimensions()
+ self.layers = {}
+ for i=1,6 do
+ table.insert(self.layers, Layer(width, height))
+ end
+ self.layers[1].ratio = 0
+ -- TODO: Scaled layers for Rays and future extensions.
+ do
+ local layer = Layer(320, 180)
+ layer.ratio = 0
+ layer.scale = 1
+ table.insert(self.layers, layer) -- 7
+ end
+end
+
--- Builds map using one of tables frin config files located in `config/maps/` directory.
function World:buildMap ()
for _,op in pairs(self.map.create) do
@@ -119,6 +122,7 @@ function World:createNaut (x, y, name)
return h
end
+-- TODO: Sprites' in general don't take actual Image in constructor. That is not only case of Decoration.
function World:createDecoration (x, y, sprite)
local d = Decoration(x, y, self, sprite)
table.insert(self.entities, d)
@@ -140,8 +144,6 @@ function World:createRay (naut)
return r
end
--- TODO: Sprites' in general don't take actual Image in constructor. That is not only case of Decoration.
--- TODO: Once entities are stored inside single table create single `insertEntity` method for World.
function World:insertCloud (cloud)
table.insert(self.entities, cloud)
cloud.layer = self.layers[2]