From 13e368bc2c35c35369a1f6bf76778d88cae240da Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 22 May 2016 19:51:51 +0200 Subject: More on maps --- world.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'world.lua') diff --git a/world.lua b/world.lua index 62490b9..2580e0e 100644 --- a/world.lua +++ b/world.lua @@ -42,6 +42,11 @@ function World:new(map, ...) o.Effects = e -- Random init math.randomseed(os.time()) + -- Map + local map = map or "default" + o:loadMap(map) + -- Nauts + o:spawnNauts(...) -- Create camera o.camera = Camera:new(o) -- Cloud generator @@ -49,11 +54,6 @@ function World:new(map, ...) for i=1,5 do o:randomizeCloud(false) end - -- Map - local map = map or "default" - o:loadMap(map) - -- Nauts - o:spawnNauts(...) return o end @@ -106,12 +106,13 @@ function World:randomizeCloud(outside) outside = outside end local x,y,t,v + local m = self.map if outside then - x = -250+math.random(-30,30) + x = m.center_x-m.width+math.random(-30,30) else - x = math.random(-200,250) + x = math.random(m.center_x-m.width/2,m.center_x+m.width/2) end - y = math.random(-20, 170) + y = math.random(m.center_y-m.height/3, m.center_y+m.height/3) t = math.random(1,3) v = math.random(8,18) self:createCloud(x, y, t, v) -- cgit v1.1