diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-13 04:37:07 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-13 04:37:07 +0200 |
commit | ed16d208863944f64ce42298132597345cb749bb (patch) | |
tree | 7b026657916a1499395d5e4d9d4ca665a9ff666e /not/CloudGenerator.lua | |
parent | d6ad468c42ba9dcd8697109ac8e30c4ccdaa7c32 (diff) | |
download | roflnauts-ed16d208863944f64ce42298132597345cb749bb.zip roflnauts-ed16d208863944f64ce42298132597345cb749bb.tar.gz roflnauts-ed16d208863944f64ce42298132597345cb749bb.tar.bz2 |
Clouds are now counted, their number is limited and can be configured
Diffstat (limited to 'not/CloudGenerator.lua')
-rw-r--r-- | not/CloudGenerator.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/not/CloudGenerator.lua b/not/CloudGenerator.lua index 3285938..e9d8ed7 100644 --- a/not/CloudGenerator.lua +++ b/not/CloudGenerator.lua @@ -4,16 +4,16 @@ CloudGenerator = require "not.Object":extends() require "not.Cloud" --- TODO: Allow map config to modify cloud styles: maximum cloud count, animations and atlas. -function CloudGenerator:new (atlas, animations, world) +function CloudGenerator:new (atlas, animations, count, world) self.world = world self.atlas = atlas self.quads = animations - self.count = 18 + self.count = count self.interval = 6 self.timer = 0 end +-- TODO: This was a bad idea. Move Cloud creation back to World, pass created Cloud here for configuration. function CloudGenerator:createCloud (x, y, style) local cloud = Cloud(x, y, self.world, self.atlas) cloud:setAnimationsList(self.quads) @@ -46,7 +46,7 @@ function CloudGenerator:getRandomStyle () end function CloudGenerator:run (count, inside) - local count = count or 1 + count = count or 1 for i=1,count do local x, y = self:getRandomPosition(inside) local style = self:getRandomStyle() @@ -56,10 +56,11 @@ end function CloudGenerator:update (dt) local count = self.world:getCloudsCount() - self.timer = self.timer - dt - if self.timer < 0 then + if self.timer < 0 and self.count > count then self.timer = self.timer + self.interval self:run() + else + self.timer = self.timer - dt end end |