forked from Hornwall/flappy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipe.rb
More file actions
28 lines (24 loc) · 628 Bytes
/
pipe.rb
File metadata and controls
28 lines (24 loc) · 628 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
require_relative "drawable_entity"
class Pipe < DrawableEntity
def initialize(window, top, offset)
@gap_size = 80
if top
super(window, 1024, (0 - @gap_size) + offset, 0.0, Gosu::Image.new(window, "resources/images/pipe.jpg", false))
else
super(window, 1024, 768-(384 - @gap_size) + offset, 0.0, Gosu::Image.new(window, "resources/images/pipe.jpg", false))
end
@velocity = -7
end
def update
@x += @velocity
if @x - @width
kill
end
end
def collide_x?(entity)
return entity.x > @x && entity.x < @x + @width
end
def collide_y?(entity)
return entity.y > @y && entity.y < @y + @height
end
end