-
Notifications
You must be signed in to change notification settings - Fork 0
/
PipePair.pde
60 lines (50 loc) · 1.29 KB
/
PipePair.pde
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class PipePair {
int gap = 150;
int topHeight;
int bottomHeight;
boolean red = false;
Pipe bottomPipe, topPipe;
PipePair() {
topHeight = floor(random(20, height - 100 - gap));
bottomHeight = height - topHeight - gap;
bottomPipe = new Pipe(false, bottomHeight);
topPipe = new Pipe(true, topHeight);
}
PipePair(float startX) {
topHeight = floor(random(20, height - 100 - gap));
bottomHeight = height - topHeight - gap;
bottomPipe = new Pipe(false, bottomHeight);
topPipe = new Pipe(true, topHeight);
bottomPipe.x = startX;
topPipe.x = startX;
}
//Zeichne das Röhren paar
void show() {
if(red)
fill(255,1,6);
else
fill(0, 210, 0);
bottomPipe.show();
topPipe.show();
}
//Update das Röhren paar
void update() {
bottomPipe.update();
topPipe.update();
if(offScreen()) {
topHeight = floor(random(20, height - 100 - gap));
bottomHeight = height - topHeight - gap;
bottomPipe = new Pipe(false, bottomHeight);
topPipe = new Pipe(true, topHeight);
}
}
boolean offScreen() {
if(bottomPipe.x + bottomPipe.pipeWidth < 0) {
return true;
}
return false;
}
boolean collide(Bird b) {
return bottomPipe.collide(b) || topPipe.collide(b);
}
}