summaryrefslogtreecommitdiffhomepage
path: root/not/CloudGenerator.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-05 18:32:34 +0200
committerAki <nthirtyone@gmail.com>2017-09-05 18:32:34 +0200
commitdc6fd557ed955fc5f177608c186768e29c7778c6 (patch)
treee20caaafef5a49108efc6f005652ee8dd532c701 /not/CloudGenerator.lua
parent69eebe12baa0804cacf7285d1fdc20f42334dc27 (diff)
downloadroflnauts-dc6fd557ed955fc5f177608c186768e29c7778c6.zip
roflnauts-dc6fd557ed955fc5f177608c186768e29c7778c6.tar.gz
roflnauts-dc6fd557ed955fc5f177608c186768e29c7778c6.tar.bz2
Cloud clean-up, moving methods from World to CloudGenerator
Diffstat (limited to 'not/CloudGenerator.lua')
-rw-r--r--not/CloudGenerator.lua54
1 files changed, 52 insertions, 2 deletions
diff --git a/not/CloudGenerator.lua b/not/CloudGenerator.lua
index 0620cdd..a26cc77 100644
--- a/not/CloudGenerator.lua
+++ b/not/CloudGenerator.lua
@@ -1,12 +1,62 @@
--- Generates clouds over time with randomized positions and styles.
+-- Also used as factory for Clouds.
CloudGenerator = require "not.Object":extends()
-function CloudGenerator:new (world, styles)
+require "not.Cloud"
+
+-- TODO: Allow map config to modify cloud styles.
+local animations = {
+ default = {
+ [1] = love.graphics.newQuad( 1, 1, 158,47, 478,49),
+ frames = 1,
+ repeated = true
+ },
+ default2 = {
+ [1] = love.graphics.newQuad(160, 1, 158,47, 478,49),
+ frames = 1,
+ repeated = true
+ },
+ default3 = {
+ [1] = love.graphics.newQuad(319, 1, 158,47, 478,49),
+ frames = 1,
+ repeated = true
+ }
+}
+
+function CloudGenerator:new (world)
self.world = world
+ self.atlas = "assets/clouds.png"
+ self.quads = animations
+end
+
+function CloudGenerator:createCloud (x, y)
+ local cloud = Cloud(x, y, self.world, self.atlas)
+ cloud:setAnimationsList(self.quads)
+ cloud:setVelocity(13, 0)
+ cloud:setBoundary(340, 320)
+ return cloud
+end
+
+function CloudGenerator:randomize (outside)
+ if outside == nil then
+ outside = true
+ else
+ outside = outside
+ end
+ local x,y,t,v
+ 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)
+ 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)
end
function CloudGenerator:update (dt)
-
+ local count = self.world:getCloudsCount()
end
return CloudGenerator