Hardware Reference
In-Depth Information
8
The setup() method sets all the
initial conditions for the game, and
then starts the server.
void setup() {
// set the window size:
size(480, 640);
// set the frame rate:
frameRate(90);
// set the default font alignment:
textAlign(CENTER);
// set no borders on drawn shapes:
noStroke();
// set the rectMode so that all rectangle dimensions
// are from the center of the rectangle (see Processing reference):
rectMode(CENTER);
// set up all the pong details:
// initialize the delay counter:
delayCounter = millis();
// initialize paddle positions for the first player.
// these will be incremented with each new player:
nextTopPaddleV = 50;
nextBottomPaddleV = height - 50;
// initialize the ball in the center of the screen:
ballPosV = height / 2;
ballPosH = width / 2;
// Start the server:
myServer = new Server(this, port);
}
8
The draw() method updates
the screen using a method called
drawGame() , and it listens for any
messages from existing clients using
the listenToClients() method.
void draw() {
drawGame();
listenToClients();
}
 
Search WWH ::




Custom Search