-
Notifications
You must be signed in to change notification settings - Fork 0
/
PipePair.pde
53 lines (33 loc) · 1.17 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
public class PipePair{
PVector positionTop = new PVector();
PVector positionBottom = new PVector();
int pipeCenter_height;
int pipeHole_dimension;
int red;
int green;
int blue;
int VELOCITY=20; // suggested value 20
int PIPE_WIDTH=300;
PipePair(int distance, int pipeCenter_height, int pipeHole_dimension,
int red, int green, int blue ){
this.pipeCenter_height = pipeCenter_height;
this.pipeHole_dimension = pipeHole_dimension;
this.red = red;
this.green = green;
this.blue = blue;
this.positionTop.x = distance;
this.positionBottom.x = distance;
this.positionTop.y = pipeCenter_height - pipeHole_dimension/2;
this.positionBottom.y = pipeCenter_height + pipeHole_dimension/2;
}
public void update(){
positionTop.x -= VELOCITY;
positionBottom.x -= VELOCITY;
fill(red, green, blue);
rect(this.positionTop.x, this.positionTop.y, PIPE_WIDTH, -height);
rect(this.positionBottom.x, this.positionBottom.y, PIPE_WIDTH, +height);
}
public boolean isAlive(){
return (positionTop.x + PIPE_WIDTH >=0);
}
}