-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPipe.lua
More file actions
28 lines (24 loc) · 768 Bytes
/
Pipe.lua
File metadata and controls
28 lines (24 loc) · 768 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
Pipe = Class{}
pipe_width = 70
pipe_height = 288
local images = {
['1'] = love.graphics.newImage('src/images/pipe1.png'),
['2'] = love.graphics.newImage('src/images/pipe2.png'),
['3'] = love.graphics.newImage('src/images/pipe3.png'),
['4'] = love.graphics.newImage('src/images/pipe4.png')
}
function Pipe:init(orientation, y)
self.x = virtual_width
self.y = y
self.image = images[tostring(math.random(1,4))]
self.width = pipe_width
self.height = pipe_height
self.orientation = orientation
end
function Pipe:render()
love.graphics.draw(self.image, self.x,
(self.orientation == 'top' and self.y + pipe_height or self.y),
0, -- rotation
1, -- X scale
self.orientation == 'top' and -1 or 1) -- Y scale
end