-
Notifications
You must be signed in to change notification settings - Fork 1
/
RightPaddle.pde
41 lines (37 loc) · 948 Bytes
/
RightPaddle.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
class RightPaddle {
float x;
float y;
float w;
float h;
RightPaddle() {
w = 20;
h = 60;
x = width-3*w;
y = height/2;
}
void displayAndMove(float tempY) {
y = tempY;
y = constrain (y-h/2, 0, height-h); // Right paddle is controlled with mouse
noStroke();
fill(255);
rect(x, y, w, h);
}
void display() {
noStroke();
fill(255);
rect(x, y, w, h);
}
void move() { // Right paddle is controlled with Up and Down arrow keys
if (keyPressed) {
if (key == CODED) {
if (keyCode == UP) {
y -= level*1.5 ; // Right paddle speed is determined by level
}
if (keyCode == DOWN) {
y += level*1.5; // Right paddle speed is determined by level
}
}
y = constrain (y, 0, height-h); // Right paddle is constrained within the screen
}
}
}