-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaviao.lua
More file actions
33 lines (27 loc) · 796 Bytes
/
aviao.lua
File metadata and controls
33 lines (27 loc) · 796 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
-- Aviao, inimigo de Cloud!
require 'class'
Aviao = class()
function Aviao:init(posx, posy)
self.image = love.graphics.newImage("aviao.png") --sprite
self.posx = posx -- posicao x
self.posy = posy -- posicao y
self.vely = math.random()*100 - 50;
self.velx = 250;
end
function Aviao:__tostring()
return self.posx..', '..self.posy
end
function Aviao:update(dt)
-- movimentacao de Aviao
if self.posx > -50 then
self.posx = self.posx - self.velx * dt
self.posy = self.posy - self.vely * dt
else
self.posx = love.graphics.getWidth() + math.random()*500
self.posy = math.random()*love.graphics.getHeight()
self.vely = math.random()*50 - 25;
end
end
function Aviao:draw()
love.graphics.draw(self.image, self.posx, self.posy, 0, 0.5, 0.5)
end