-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcombustivel.lua
47 lines (36 loc) · 1009 Bytes
/
combustivel.lua
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
38
39
40
41
42
43
44
45
46
47
combustivel = {}
-- Gerando combustiveis na tela
function combustivel.spawn()
vetor = {}
vetor.imagem = love.graphics.newImage("/imagens/battery.png")
vetor.x = love.math.random(20, love.window.getWidth() - 20)
vetor.y = 0
vetor.largura = vetor.imagem:getWidth()/2
vetor.altura = vetor.imagem:getHeight()/2
table.insert(combustivel.tabela, vetor)
end
-- Carregando propriedades do Combustivel
function combustivel.load()
combustivel.tabela = {}
combustivel.tempo = 0
end
-- Atualizando as propriedades do Combustivel
function combustivel.update(dt)
combustivel.tempo = combustivel.tempo + 0.01
if combustivel.tempo >= 2 then
combustivel.spawn()
combustivel.tempo = 0
end
for i,c in ipairs(combustivel.tabela) do
if c.y > love.window.getHeight() + 10 then
table.remove(combustivel.tabela, i)
end
c.y = c.y + 4
end
end
-- Desenhando combustiveis na tela
function combustivel.draw()
for _,c in pairs(combustivel.tabela) do
love.graphics.draw(c.imagem, c.x, c.y)
end
end