-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpong1_3.pde
45 lines (41 loc) · 1.06 KB
/
pong1_3.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
import processing.sound.*; // Import Processing Sound library
SoundFile paddle;
SoundFile sides;
SoundFile point;
PFont font;
Ball ball;
Score score;
Net net;
RightPaddle paddleR;
LeftPaddle paddleL;
int level = 2; // Level determines ball speed and left paddle speed
void setup() {
// Set screen size
size(600, 400);
// Cursor is not visible
noCursor();
// Create sound files
paddle = new SoundFile(this, "pong_paddle.wav");
sides = new SoundFile(this, "pong_sides.wav");
point = new SoundFile(this, "pong_point.wav");
// Create font file
font = createFont("bit5x3.ttf", 48);
// Initialize objects
ball = new Ball();
score = new Score();
net = new Net();
paddleR = new RightPaddle();
paddleL = new LeftPaddle();
}
void draw() {
background(0);
score.display();
net.display();
ball.display();
ball.move(paddleR, paddleL);
paddleL.display();
paddleL.move();
paddleR.displayAndMove(mouseY); // Right paddle is controlled by mouse
//paddleR.move();
//paddleR.display(); // Right paddle is controlled by keys
}