-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudinho_spawner.lua
More file actions
37 lines (32 loc) · 856 Bytes
/
cloudinho_spawner.lua
File metadata and controls
37 lines (32 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- Cloudinho Spawner
require 'class'
require 'cloudinho'
require 'cloud_strife'
require 'collision'
CloudinhoSpawner = class()
function CloudinhoSpawner:init()
self.cloudinhos = {}
self.time1 = love.timer.getTime()
end
function CloudinhoSpawner:update(dt, strife)
-- movimentacao de cloudinho
self.time2 = love.timer.getTime()
if (self.time2 - self.time1 > 3) then
if math.random() > 0.5 then
table.insert(self.cloudinhos, Cloudinho(1000, math.random()*love.graphics.getHeight()))
end
self.time1 = self.time2
end
for i, cloudinho in pairs(self.cloudinhos) do
cloudinho:update(dt)
if isColliding(cloudinho, strife) then
strife:raiseLife(20)
self.cloudinhos[i] = nil
end
end
end
function CloudinhoSpawner:draw()
for i, cloudinho in pairs(self.cloudinhos) do
cloudinho:draw()
end
end