-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipe.js
77 lines (66 loc) · 2.28 KB
/
pipe.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/****************************************************
* pipe.js
*
* Our predefined variables:
*
* - speed contains the pipe speed that we will use for moving animation.
* - width the width of the pipe.
* - x x-axis position of pipe.
* - topY the upper pipe's y-axis positioning.
* - bottomY the lower pipe's y-axis positioning.
* - topHeight the upper pipe's height.
* - bottomHeight the lower pipe's height.
*
* Our predefined methods:
*
* - show() will be used for drawing an upper and lower pipe.
* - update() will be used for animation, in this case, moving the pipes from right to left on the canvas.
* - hits() will be used for checking if our reindeer hits a pipe.
* - pass() will be used for checking if our reindeer passes (NOT hits) a pipe.
* - offscreen() will be used for checking of the pipe has moved outside the canvas.
*
****************************************************/
class Pipe {
speed = 2;
topHeight = random(CANVAS_HEIGHT / 2);
width = 20;
x = CANVAS_WIDTH;
topY = 0;
bottomHeight = random(CANVAS_HEIGHT / 2);
bottomY = CANVAS_HEIGHT - this.bottomHeight;
/****************************************************
* Create pipes
* Use fill and rect from p5 together with
* the variables in the top
* @custom
****************************************************/
show() {
}
/****************************************************
* Each pipe starts to the right of the canvas and
* moves to the left
* This function updates in draw()
* @custom
****************************************************/
update() {
}
/****************************************************
* Hit detection: when the reindeer hits the pipe
* @custom
****************************************************/
hits(reindeer) {
}
/****************************************************
* When the reindeer passes a pipe
* @custom
****************************************************/
pass(reindeer) {
}
/****************************************************
* Check if the pipe is offscreen or not
* Use the variables in the top
* @custom
****************************************************/
offscreen() {
}
}