-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpipe_pair.rb
More file actions
37 lines (29 loc) · 742 Bytes
/
Copy pathpipe_pair.rb
File metadata and controls
37 lines (29 loc) · 742 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
35
36
37
require_relative "entity"
require_relative "pipe"
class PipePair < Entity
attr_reader :pipes
def initialize(window, offset)
super(window)
@pipe_top = Pipe.new(@window, true, offset)
@pipe_bottom = Pipe.new(@window, false, offset)
end
def update
@pipe_top.update
@pipe_bottom.update
if collide_x?(@window.calle) && collide_y?(@window.calle)
@window.calle.kill
elsif collide_x?(@window.calle) && !collide_y?(@window.calle)
puts "got score!"
end
end
def collide_x?(entity)
return @pipe_top.collide_x?(entity)|| @pipe_bottom.collide_x?(entity)
end
def collide_y?(entity)
return @pipe_top.collide_y?(entity) || @pipe_bottom.collide_y?(entity)
end
def draw
@pipe_top.draw
@pipe_bottom.draw
end
end