-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pipe.pde
59 lines (48 loc) · 1.03 KB
/
Pipe.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
class Pipe {
int pipeXPos = width + 30;
int pipeYTop, pipeYBottom;
PImage pipeTop, pipeBottom;
boolean hasScored;
int pipeHeight, pipeWidth;
boolean hasCreatedNewPipe = false;
Pipe() {
imageMode(CORNER);
pipeTop = loadImage("pipeDown.png");
pipeBottom = loadImage("pipeUp.png");
hasScored = false;
pipeHeight = pipeTop.height;
pipeWidth = pipeTop.width;
pipeYTop = int(random(-475, -125));
pipeYBottom = (pipeHeight + pipeYTop) + 90;
}
void movePipe() {
pipeXPos -= 1.5;
}
void displayPipe() {
image(pipeTop, pipeXPos, pipeYTop);
image(pipeBottom, pipeXPos, pipeYBottom);
}
boolean checkOnScreen() {
if (getPipeX() <= -60) {
return false;
}
else {
return true;
}
}
int getPipeX() {
return pipeXPos;
}
int getPipeYTop() {
return pipeYTop;
}
int getPipeYBottom() {
return pipeYBottom;
}
int getPipeHeight() {
return pipeYTop + pipeHeight ;
}
int getPipeRight() {
return getPipeX() + pipeWidth;
}
}//class