-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlien.lua
More file actions
31 lines (27 loc) · 724 Bytes
/
Copy pathAlien.lua
File metadata and controls
31 lines (27 loc) · 724 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
Alien={}
Alien.xpose=700
Alien.ypose=100
Alien.speed=100
Alien.imagePath = 'alien.png'
Alien.image= nil
Alien.width = 20
Alien.height = 20
Alien.__index = function (table, key)
return Alien.key
end
function Alien:move(dt)
self.xpose=self.xpose-0.1*self.speed*dt
end
function Alien.new(speed)
local object = object or {}
object.xpose = 10 * love.graphics.getWidth() / 11
object.ypose = (love.graphics.getHeight() - 300) * math.random() + 150
object.speed = speed or Alien.speed
object.width = Alien.width
object.height = Alien.height
setmetatable(object, Alien)
return object
end
function Alien:getRectangle()
return {self.xpose, self.ypose, self.width, self.height};
end