summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--conf.lua2
-rw-r--r--main.lua3
-rw-r--r--world.lua40
3 files changed, 36 insertions, 9 deletions
diff --git a/conf.lua b/conf.lua
index 6a9ccb2..c8c315a 100644
--- a/conf.lua
+++ b/conf.lua
@@ -4,5 +4,5 @@ function love.conf(t)
t.window.icon = "assets/icon.png"
t.window.width = 315*4
t.window.height = 200*4
- t.console = false
+ t.console = true
end \ No newline at end of file
diff --git a/main.lua b/main.lua
index e393d0c..35e9147 100644
--- a/main.lua
+++ b/main.lua
@@ -25,9 +25,6 @@ function love.load ()
w:createNaut(290/2-10, 180/2 - 80, "assets/leon.png")
w:createNaut(290/2+10, 180/2 - 80, "assets/lonestar.png")
- w:randomizeCloud()
- w:randomizeCloud()
- w:randomizeCloud()
-- Temporary settings for second player
w.Nauts[2].name = "Player2"
diff --git a/world.lua b/world.lua
index c692ceb..1d1c6d4 100644
--- a/world.lua
+++ b/world.lua
@@ -6,11 +6,15 @@
-- Metatable of `World`
-- nils initialized in constructor
World = {
+ -- inside
world = nil,
Nauts = nil,
Platforms = nil,
Clouds = nil,
- camera = nil
+ camera = nil,
+ -- cloud generator
+ clouds_delay = 6,
+ clouds_initial = nil
}
-- Constructor of `World` ZA WARUDO!
@@ -34,6 +38,11 @@ function World:new()
math.randomseed(os.time())
-- Create camera
o.camera = Camera:new()
+ -- Cloud generator
+ o.clouds_initial = o.clouds_delay
+ for i=1,5 do
+ o:randomizeCloud(false)
+ end
return o
end
@@ -53,12 +62,21 @@ function World:createCloud(x, y, t, v)
end
-- Randomize Cloud creation
-function World:randomizeCloud()
+function World:randomizeCloud(outside)
+ if outside == nil then
+ outside = true
+ else
+ outside = outside
+ end
local x,y,t,v
- x = -200+math.random(-20,20)
+ if outside then
+ x = -250+math.random(-30,30)
+ else
+ x = math.random(-200,250)
+ end
y = math.random(0, 160)
t = math.random(1,3)
- v = math.random(4,14)
+ v = math.random(8,18)
self:createCloud(x, y, t, v)
end
@@ -73,8 +91,20 @@ function World:update(dt)
naut:update(dt)
end
-- Clouds
+ -- generator
+ local n = table.getn(self.Clouds)
+ self.clouds_delay = self.clouds_delay - dt
+ if self.clouds_delay < 0 and
+ n < 12
+ then
+ self:randomizeCloud()
+ self.clouds_delay = self.clouds_delay + self.clouds_initial
+ end
+ -- movement
for _,cloud in pairs(self.Clouds) do
- cloud:update(dt)
+ if cloud:update(dt) > 340 then
+ table.remove(self.Clouds, _)
+ end
end
end