diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-06 02:28:52 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-06 02:28:52 +0200 |
commit | 0ef657d12d523f3805422bfc1cb840e1a481af03 (patch) | |
tree | f4ca36769ab764e5ce3173fb5f7e6dcf12a992cd /not | |
parent | e223ae4d3495ae6060017bb60b11a322ff39623c (diff) | |
download | roflnauts-0ef657d12d523f3805422bfc1cb840e1a481af03.zip roflnauts-0ef657d12d523f3805422bfc1cb840e1a481af03.tar.gz roflnauts-0ef657d12d523f3805422bfc1cb840e1a481af03.tar.bz2 |
Some actual functionality added to CloudGen
Diffstat (limited to 'not')
-rw-r--r-- | not/CloudGenerator.lua | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/not/CloudGenerator.lua b/not/CloudGenerator.lua index da5ddb2..fb1b617 100644 --- a/not/CloudGenerator.lua +++ b/not/CloudGenerator.lua @@ -28,6 +28,8 @@ function CloudGenerator:new (world) self.atlas = "assets/clouds.png" self.quads = animations self.count = 18 + self.interval = 6 + self.timer = 0 end function CloudGenerator:createCloud (x, y, style) @@ -39,27 +41,27 @@ function CloudGenerator:createCloud (x, y, style) return cloud end +-- TODO: CloudGen's randomization methods are too static (not configurable). function CloudGenerator:getRandomPosition (inside) - return 20, 20 + local x, y + local map = self.world.map + if not inside then + x = map.center.x - map.width*1.2 + love.math.random(-50, 20) + else + x = love.math.random(map.center.x - map.width / 2, map.center.x + map.width / 2) + end + y = love.math.random(map.center.y - map.height / 2, map.center.y + map.height / 2) + return x, y end function CloudGenerator:getRandomStyle () - return "default" -end - ---[[ -function CloudGenerator:randomize (outside) - local m = self.map - if outside then - x = m.center.x-m.width*1.2+love.math.random(-50,20) - else - x = love.math.random(m.center.x-m.width/2,m.center.x+m.width/2) + local num = love.math.random(1, 3) + local style = "default" + if num > 1 then + style = style .. tostring(num) end - y = love.math.random(m.center.y-m.height/2, m.center.y+m.height/2) - t = love.math.random(1,3) - v = love.math.random(8,18) + return style end -]] function CloudGenerator:run (count, inside) local count = count or 1 @@ -72,7 +74,11 @@ end function CloudGenerator:update (dt) local count = self.world:getCloudsCount() - self:run() + self.timer = self.timer - dt + if self.timer < 0 then + self.timer = self.timer + self.interval + self:run() + end end return CloudGenerator |