-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbalao.lua
More file actions
34 lines (27 loc) · 794 Bytes
/
balao.lua
File metadata and controls
34 lines (27 loc) · 794 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
-- Balão, inimigo do cloud!
require 'class'
Balao = class()
function Balao:init(posx, posy)
self.image = love.graphics.newImage("balao.png") --sprite
self.posx = posx -- posicao x
self.posy = posy -- posicao y
self.velx = math.random()*30 - 15
self.vely = 30
end
function Balao:__tostring()
return self.posx..', '..self.posy
end
function Balao:update(dt)
-- movimentacao de Balao
if self.posy > -50 then
self.posx = self.posx - self.velx * dt
self.posy = self.posy - self.vely * dt
else
self.posy = love.graphics.getHeight()+math.random()*200
self.posx = math.random()*love.graphics.getWidth()
self.velx = math.random()*30 - 15
end
end
function Balao:draw()
love.graphics.draw(self.image, self.posx, self.posy, 0, 0.5, 0.5)
end