Inviso-pong

Creators: Adam Bodenmiller, Mark Malkowski, Ryan Mc Henry, and Nick Wozniak

Brief description:

This is pong with a twist, the paddles are invisible. depending on what mode you choose the ball will be almost invisible, the paddles will shrink, but in all of them the paddle goes back to the middle.

int center = 250; //paddle repositioning point

int gapTitle = 280; //X-margin of title

int marginTitle = 100; //Y-margin of title

int marginPMode = 200; // Y-margin of practice mode

int marginBMode = 300; //Y-margin of beginner mode

int marginIMode = 400; //Y-margin of intermediate mode

int marginEMode = 500; //Y-margin of expert mode

int gapMode = 80; //X-margin of Modes

int PlengthP1 = 220; //Colors P1's paddle in practice mode

int PlengthP2 = 220; //Colors P2's paddle in practice mode

int lengthP1 = 0; //Removes P1's paddles fill in beginner, intermediate, and expert mode

int lengthP2 = 0; //Removes P2's paddles fill in beginner, intermediate, and expert mode

int RLengthP1 = 220; //Length of P1's paddle

int RLengthP2 = 220; //Length of P2's paddle

int gapP1 = 440; //X-margin of P1's score

int gapP2 = 560; //X-margin of P2's score

int margin = 40; //Y-margin of score

int radius = 20; //radius of ball

int x = 500; //X-coordinate of ball

int y = 360; //Y-coordinate of ball

int xP1 = 70; //X-coordinate of P1's paddle

int xP2 = 890; //X-coordinate of P2's paddle

int yP1 = 250; //Y-coordinate of P1's paddle

int yP2 = 250; //Y-coordinate of P2's paddle

int ydiff = 60; //Paddle manual speed

int cdiff = 15; //Paddle center speed

float speedx = 10; //X-direction speed of ball

float speedy = 4; //Y-direction speed of ball

int directionx = 1; //X-direction

int directiony = 1; //Y-direction

PFont fontA;

boolean catalyst = false; //Initiates pause

boolean pause = false; //True initiates pause screen

boolean practice = false; //Initiates practice mode

boolean beginner = false; //initiates begginner mode

boolean intermediate = false; //initiates intermediate mode

boolean expert = false; //inititates expert mode

boolean P1key = false; //locks P2's key

boolean P2key = false; //locks P1's key

boolean score0P1 = true; //shows score when true, it shows that score.

boolean score1P1 = false;

boolean score2P1 = false;

boolean score3P1 = false;

boolean score4P1 = false;

boolean score5P1 = false;

boolean score6P1 = false;

boolean score7P1 = false;

boolean score8P1 = false;

boolean score9P1 = false;

boolean score10P1 = false;

boolean score0P2 = true;

boolean score1P2 = false;

boolean score2P2 = false;

boolean score3P2 = false;

boolean score4P2 = false;

boolean score5P2 = false;

boolean score6P2 = false;

boolean score7P2 = false;

boolean score8P2 = false;

boolean score9P2 = false;

boolean score10P2 = false;

void setup() {

fontA = loadFont("CharterBT-Roman-48.vlw"); // type of font used.

textAlign(CENTER); // point specified for each letter is in the center.

textFont(fontA, 50); // everything in the font is that size.

size(1000, 720); // size of the scree

background(0); // color of the background (black)

noFill();

text ('I', gapTitle, marginTitle); // text is the main screen, including title and difficulties (inviso-pong, practice, etc)

The gapTitle is the distance between the letters (X) and the margin title is the Y axis part.

noFill();

text ('N', gapTitle + 40, marginTitle);

noFill();

text ('V', gapTitle + 80, marginTitle);

noFill();

text ('I', gapTitle + 120, marginTitle);

noFill();

text ('S', gapTitle + 160, marginTitle);

noFill();

text ('O', gapTitle + 200, marginTitle);

fill(255);

text ('-', gapTitle + 240, marginTitle);

fill(255);

text ('P', gapTitle + 280, marginTitle);

fill(255);

text ('O', gapTitle + 320, marginTitle);

fill(255);

text ('N', gapTitle + 360, marginTitle);

fill(255);

text ('G', gapTitle + 400, marginTitle);

fill(255);

text ('P', gapMode, marginPMode);

fill(255);

text ('r', gapMode + 20, marginPMode);

fill(255);

text ('e', gapMode + 40, marginPMode);

fill(255);

text ('s', gapMode + 60, marginPMode);

fill(255);

text ('s', gapMode + 80, marginPMode);

fill(255);

text ('P', gapMode + 120, marginPMode);

fill(255);

text ('t', gapMode + 160, marginPMode);

fill(255);

text ('o', gapMode + 180, marginPMode);

fill(255);

text ('e', gapMode + 220, marginPMode);

fill(255);

text ('n', gapMode + 240, marginPMode);

fill(255);

text ('t', gapMode + 260, marginPMode);

fill(255);

text ('e', gapMode + 280, marginPMode);

fill(255);

text ('r', gapMode + 300, marginPMode);

fill(255);

text ('P', gapMode + 340, marginPMode);

fill(255);

text ('r', gapMode + 360, marginPMode);

fill(255);

text ('a', gapMode + 380, marginPMode);

fill(255);

text ('c', gapMode + 400, marginPMode);

fill(255);

text ('t', gapMode + 420, marginPMode);

fill(255);

text ('i', gapMode + 440, marginPMode);

fill(255);

text ('c', gapMode + 460, marginPMode);

fill(255);

text ('e', gapMode + 480, marginPMode);

fill(255);

text ('M', gapMode + 520, marginPMode);

fill(255);

text ('o', gapMode + 550, marginPMode);

fill(255);

text ('d', gapMode + 570, marginPMode);

fill(255);

text ('e', gapMode + 590, marginPMode);

fill(255);

text ('P', gapMode, marginBMode);

fill(255);

text ('r', gapMode + 20, marginBMode);

fill(255);

text ('e', gapMode + 40, marginBMode);

fill(255);

text ('s', gapMode + 60, marginBMode);

fill(255);

text ('s', gapMode + 80, marginBMode);

fill(140);

text ('B', gapMode + 120, marginBMode);

fill(255);

text ('t', gapMode + 160, marginBMode);

fill(255);

text ('o', gapMode + 180, marginBMode);

fill(255);

text ('e', gapMode + 220, marginBMode);

fill(255);

text ('n', gapMode + 240, marginBMode);

fill(255);

text ('t', gapMode + 260, marginBMode);

fill(255);

text ('e', gapMode + 280, marginBMode);

fill(255);

text ('r', gapMode + 300, marginBMode);

fill(140);

text ('B', gapMode + 340, marginBMode);

fill(140);

text ('e', gapMode + 360, marginBMode);

fill(140);

text ('g', gapMode + 380, marginBMode);

fill(140);

text ('i', gapMode + 400, marginBMode);

fill(140);

text ('n', gapMode + 420, marginBMode);

fill(140);

text ('n', gapMode + 450, marginBMode);

fill(140);

text ('e', gapMode + 480, marginBMode);

fill(140);

text ('r', gapMode + 500, marginBMode);

fill(255);

text ('M', gapMode + 540, marginBMode);

fill(255);

text ('o', gapMode + 570, marginBMode);

fill(255);

text ('d', gapMode + 590, marginBMode);

fill(255);

text ('e', gapMode + 610, marginBMode);

fill(255);

text ('P', gapMode, marginIMode);

fill(255);

text ('r', gapMode + 20, marginIMode);

fill(255);

text ('e', gapMode + 40, marginIMode);

fill(255);

text ('s', gapMode + 60, marginIMode);

fill(255);

text ('s', gapMode + 80, marginIMode);

fill(75);

text ('I', gapMode + 120, marginIMode);

fill(255);

text ('t', gapMode + 160, marginIMode);

fill(255);

text ('o', gapMode + 180, marginIMode);

fill(255);

text ('e', gapMode + 220, marginIMode);

fill(255);

text ('n', gapMode + 240, marginIMode);

fill(255);

text ('t', gapMode + 260, marginIMode);

fill(255);

text ('e', gapMode + 280, marginIMode);

fill(255);

text ('r', gapMode + 300, marginIMode);

fill(75);

text ('I', gapMode + 340, marginIMode);

fill(75);

text ('n', gapMode + 360, marginIMode);

fill(75);

text ('t', gapMode + 380, marginIMode);

fill(75);

text ('e', gapMode + 400, marginIMode);

fill(75);

text ('r', gapMode + 425, marginIMode);

fill(75);

text ('m', gapMode + 455, marginIMode);

fill(75);

text ('e', gapMode + 485, marginIMode);

fill(75);

text ('d', gapMode + 505, marginIMode);

fill(75);

text ('i', gapMode + 525, marginIMode);

fill(75);

text ('a', gapMode + 545, marginIMode);

fill(75);

text ('t', gapMode + 565, marginIMode);

fill(75);

text ('e', gapMode + 585, marginIMode);

fill(255);

text ('M', gapMode + 625, marginIMode);

fill(255);

text ('o', gapMode + 655, marginIMode);

fill(255);

text ('d', gapMode + 675, marginIMode);

fill(255);

text ('e', gapMode + 695, marginIMode);

fill(255);

text ('P', gapMode, marginEMode);

fill(255);

text ('r', gapMode + 20, marginEMode);

fill(255);

text ('e', gapMode + 40, marginEMode);

fill(255);

text ('s', gapMode + 60, marginEMode);

fill(255);

text ('s', gapMode + 80, marginEMode);

fill(15);

text ('E', gapMode + 120, marginEMode);

fill(255);

text ('t', gapMode + 160, marginEMode);

fill(255);

text ('o', gapMode + 180, marginEMode);

fill(255);

text ('e', gapMode + 220, marginEMode);

fill(255);

text ('n', gapMode + 240, marginEMode);

fill(255);

text ('t', gapMode + 260, marginEMode);

fill(255);

text ('e', gapMode + 280, marginEMode);

fill(255);

text ('r', gapMode + 300, marginEMode);

fill(15);

text ('E', gapMode + 340, marginEMode);

fill(15);

text ('x', gapMode + 360, marginEMode);

fill(15);

text ('p', gapMode + 380, marginEMode);

fill(15);

text ('e', gapMode + 400, marginEMode);

fill(15);

text ('r', gapMode + 420, marginEMode);

fill(15);

text ('t', gapMode + 440, marginEMode);

fill(255);

text ('M', gapMode + 480, marginEMode);

fill(255);

text ('o', gapMode + 510, marginEMode);

fill(255);

text ('d', gapMode + 530, marginEMode);

fill(255);

text ('e', gapMode + 550, marginEMode);

fill(255);

rect(xP1, yP1, 40, lengthP1); // The paddles, the most important aspect of the WHOLE game

//(rect is a rectangle and the fill gives it color the XP1,yP1,and 40 are the coordinates for

//the player one paddle as is similar with the P2 paddle but with different coordinates.

fill(255);

rect(xP2, yP2, 40, lengthP2); //P2 paddle ,

fill(255);

}

void draw() {

if (keyPressed) { //Everything is assumed to be false at the beginning, but when pressed becomes true. this is for each of the modes.

if (key == 'p') {

practice = true;

}

if (key == 'b') {

beginner = true; //plays beginner mode

}

if (key == 'i') {

intermediate = true; //plays intermediate mode

}

if (key == 'e') { // need we explain this one?

expert = true;

}

if (key == 'r') { // r press causes the pause screen to activate.

practice = false;

beginner = false;

intermediate = false;

expert = false;

if (pause == false) {

pause = true;

if (catalyst == true) { //catalyst is what stops the game to freeze

pause = false; //pause is what causes the words on the pause screen to pop up

catalyst = false;

}

}

}

if (pause) {

fill(255);

text ('P', gapMode + 410, 360); //When the game is paused these letters come up to fulfill pauses purpose.

fill(140);

text ('B', gapMode + 410, 400);

fill(75);

text ('I', gapMode + 410, 440);

fill(15);

text ('E', gapMode + 410, 480);

fill(255);

text ('a', gapMode + 430, 360);

fill(255);

text ('u', gapMode + 450, 360);

fill(255);

text ('s', gapMode + 470, 360);

fill(255);

text ('e', gapMode + 490, 360);

fill(255);

text ('d', gapMode + 510, 360);

fill(127);

text ('-', gapMode + 550, 340);

fill(127);

text ('_', gapMode + 580, 340);

fill(127);

text ('-', gapMode + 610, 340);

fill(15);

text ('>', gapMode + 470, 495);

fill(15);

text ('_', gapMode + 500, 495);

fill(15);

text ('<', gapMode + 530, 495);

fill(255);

catalyst = true;

}

}

if (practice) { //if practice mode is up, then the score will come up when

background(0);

if (score1P1) {

fill(255);

text ('9', gapP1, margin);

}

if (score2P1) {

fill(255);

text ('8', gapP1, margin);

}

if (score3P1) {

fill(255);

text ('7', gapP1, margin);

}

if (score4P1) {

fill(255);

text ('6', gapP1, margin);

}

if (score5P1) {

fill(255);

text ('5', gapP1, margin);

}

if (score6P1) {

fill(255);

text ('4', gapP1, margin);

}

if (score7P1) {

fill(255);

text ('3', gapP1, margin);

}

if (score8P1) {

fill(255);

text ('2', gapP1, margin);

}

if (score9P1) {

fill(255);

text ('1', gapP1, margin);

}

if (score10P1) {

fill(255);

text ('0', gapP1, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('2', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

if (score1P2) {

fill(255);

text ('9', gapP2, margin);

}

if (score2P2) {

fill(255);

text ('8', gapP2, margin);

}

if (score3P2) {

fill(255);

text ('7', gapP2, margin);

}

if (score4P2) {

fill(255);

text ('6', gapP2, margin);

}

if (score5P2) {

fill(255);

text ('5', gapP2, margin);

}

if (score6P2) {

fill(255);

text ('4', gapP2, margin);

}

if (score7P2) {

fill(255);

text ('3', gapP2, margin);

}

if (score8P2) {

fill(255);

text ('2', gapP2, margin);

}

if (score9P2) {

fill(255);

text ('1', gapP2, margin);

}

if (score10P2) {

fill(255);

text ('0', gapP2, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('1', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

fill(255);

rect(xP1, yP1, 40, PlengthP1);

fill(255);

rect(xP2, yP2, 40, PlengthP2);

fill(255);

ellipse(x, y, radius, radius);

if (yP1 > center) {

yP1 = yP1 - cdiff;

}

if (yP1 < center) {

yP1 = yP1 + cdiff;

}

if (yP2 > center) {

yP2 = yP2 - cdiff;

}

if (yP2 < center) {

yP2 = yP2 + cdiff;

}

if (P1key) {

if (keyPressed) {

if (key == 'a') {

yP1 = yP1 + ydiff;

}

if (key == 'q') {

yP1 = yP1 - ydiff;

}

}

}

if (P2key) {

if (keyPressed) {

if (key == 'l') {

yP2 = yP2 + ydiff;

}

if (key == 'o') {

yP2 = yP2 - ydiff;

}

}

}

yP1 = constrain(yP1, 0, height-RLengthP1);

yP2 = constrain(yP2, 0, height-RLengthP2);

if (x < -100) {

delay(1000);

x = 500;

y = 360;

speedx = 10;

speedy = 4;

directionx = -directionx;

RLengthP1 = 240;

if (score9P1) {

score10P1 = true;

score9P1 = false;

gapP1 -= 40;

}

if (score8P1) {

score9P1 = true;

score8P1 = false;

gapP1 -= 40;

}

if (score7P1) {

score8P1 = true;

score7P1 = false;

gapP1 -= 40;

}

if (score6P1) {

score7P1 = true;

score6P1 = false;

gapP1 -= 40;

}

if (score5P1) {

score6P1 = true;

score5P1 = false;

gapP1 -= 40;

}

if (score4P1) {

score5P1 = true;

score4P1 = false;

gapP1 -= 40;

}

if (score3P1) {

score4P1 = true;

score3P1 = false;

gapP1 -= 40;

}

if (score2P1) {

score3P1 = true;

score2P1 = false;

gapP1 -= 40;

}

if (score1P1) {

score2P1 = true;

score1P1 = false;

gapP1 -= 40;

}

if (score0P1) {

score1P1 = true;

score0P1 = false;

gapP1 -= 40;

}

}

if (x > 1100) {

delay(1000);

x = 500;

y = 360;

speedx = 10;

speedy = 4;

directionx = -directionx;

RLengthP2 = 240;

if (score9P2) {

score10P2 = true;

score9P2 = false;

gapP2 += 40;

}

if (score8P2) {

score9P2 = true;

score8P2 = false;

gapP2 += 40;

}

if (score7P2) {

score8P2 = true;

score7P2 = false;

gapP2 += 40;

}

if (score6P2) {

score7P2 = true;

score6P2 = false;

gapP2 += 40;

}

if (score5P2) {

score6P2 = true;

score5P2 = false;

gapP2 += 40;

}

if (score4P2) {

score5P2 = true;

score4P2 = false;

gapP2 += 40;

}

if (score3P2) {

score4P2 = true;

score3P2 = false;

gapP2 += 40;

}

if (score2P2) {

score3P2 = true;

score2P2 = false;

gapP2 += 40;

}

if (score1P2) {

score2P2 = true;

score1P2 = false;

gapP2 += 40;

}

if (score0P2) {

score1P2 = true;

score0P2 = false;

gapP2 += 40;

}

}

if (directionx == -1) {

P1key = true;

P2key = false;

}

if (directionx == 1) {

P2key = true;

P1key = false;

}

if ((y >= height - radius) || (y <= 0)) {

directiony = -directiony;

}

x += speedx * directionx;

y += speedy * directiony;

if (x >= xP1)

if (x <= xP1 + 50)

if (y >= yP1)

if (y <= yP1 + RLengthP1) {

directionx = -directionx;

if (y <= yP1 + RLengthP1/2) {

directiony = -directiony;

}

speedx = speedx * 1.15;

speedy = speedy * 1.15;

fill(255);

rect(xP1, yP1, 40, RLengthP1);

}

if (x <= xP2 + 40)

if (x >= xP2 - 10)

if (y >= yP2)

if (y <= yP2 + RLengthP2) {

directionx = -directionx;

if (y <= yP2 + RLengthP2/2) {

directiony = -directiony;

}

speedx = speedx * 1.15;

speedy = speedy * 1.15;

fill(255);

rect(xP2, yP2, 40, RLengthP2);

}

}

if (beginner) {

background(0);

if (score1P1) {

fill(255);

text ('9', gapP1, margin);

}

if (score2P1) {

fill(255);

text ('8', gapP1, margin);

}

if (score3P1) {

fill(255);

text ('7', gapP1, margin);

}

if (score4P1) {

fill(255);

text ('6', gapP1, margin);

}

if (score5P1) {

fill(255);

text ('5', gapP1, margin);

}

if (score6P1) {

fill(255);

text ('4', gapP1, margin);

}

if (score7P1) {

fill(255);

text ('3', gapP1, margin);

}

if (score8P1) {

fill(255);

text ('2', gapP1, margin);

}

if (score9P1) {

fill(255);

text ('1', gapP1, margin);

}

if (score10P1) {

fill(255);

text ('0', gapP1, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('2', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

if (score1P2) {

fill(255);

text ('9', gapP2, margin);

}

if (score2P2) {

fill(255);

text ('8', gapP2, margin);

}

if (score3P2) {

fill(255);

text ('7', gapP2, margin);

}

if (score4P2) {

fill(255);

text ('6', gapP2, margin);

}

if (score5P2) {

fill(255);

text ('5', gapP2, margin);

}

if (score6P2) {

fill(255);

text ('4', gapP2, margin);

}

if (score7P2) {

fill(255);

text ('3', gapP2, margin);

}

if (score8P2) {

fill(255);

text ('2', gapP2, margin);

}

if (score9P2) {

fill(255);

text ('1', gapP2, margin);

}

if (score10P2) {

fill(255);

text ('0', gapP2, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('1', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

fill(255);

rect(xP1, yP1, 40, lengthP1);

fill(255);

rect(xP2, yP2, 40, lengthP2);

fill(140);

ellipse(x, y, radius, radius);

if (yP1 > center) {

yP1 = yP1 - cdiff;

}

if (yP1 < center) {

yP1 = yP1 + cdiff;

}

if (yP2 > center) {

yP2 = yP2 - cdiff;

}

if (yP2 < center) {

yP2 = yP2 + cdiff;

}

if (P1key) {

if (keyPressed) {

if (key == 'a') {

yP1 = yP1 + ydiff;

}

if (key == 'q') {

yP1 = yP1 - ydiff;

}

}

}

if (P2key) {

if (keyPressed) {

if (key == 'l') {

yP2 = yP2 + ydiff;

}

if (key == 'o') {

yP2 = yP2 - ydiff;

}

}

}

yP1 = constrain(yP1, 0, height-RLengthP1);

yP2 = constrain(yP2, 0, height-RLengthP2);

if (x < -100) { //this is the x-axis boundary for player 1's area to give away a point. when this happens it resets to 500 (x)and 360 (y)

delay(1000);

x = 500;

y = 360;

speedx = 10; //speed reset

speedy = 4;

directionx = -directionx;

RLengthP1 = 240; //paddle length reset for when P1 loses

if (score9P1) {

score10P1 = true;

score9P1 = false;

gapP1 -= 40;

}

if (score8P1) {

score9P1 = true;

score8P1 = false;

gapP1 -= 40;

}

if (score7P1) {

score8P1 = true;

score7P1 = false;

gapP1 -= 40;

}

if (score6P1) {

score7P1 = true;

score6P1 = false;

gapP1 -= 40;

}

if (score5P1) {

score6P1 = true;

score5P1 = false;

gapP1 -= 40;

}

if (score4P1) {

score5P1 = true;

score4P1 = false;

gapP1 -= 40;

}

if (score3P1) {

score4P1 = true;

score3P1 = false;

gapP1 -= 40;

}

if (score2P1) {

score3P1 = true;

score2P1 = false;

gapP1 -= 40;

}

if (score1P1) {

score2P1 = true;

score1P1 = false;

gapP1 -= 40;

}

if (score0P1) {

score1P1 = true;

score0P1 = false;

gapP1 -= 40;

}

}

if (x > 1100) {

delay(1000);

x = 500;

y = 360;

speedx = 10;

speedy = 4;

directionx = -directionx;

RLengthP2 = 240;

if (score9P2) {

score10P2 = true;

score9P2 = false;

gapP2 += 40;

}

if (score8P2) {

score9P2 = true;

score8P2 = false;

gapP2 += 40;

}

if (score7P2) {

score8P2 = true;

score7P2 = false;

gapP2 += 40;

}

if (score6P2) {

score7P2 = true;

score6P2 = false;

gapP2 += 40;

}

if (score5P2) {

score6P2 = true;

score5P2 = false;

gapP2 += 40;

}

if (score4P2) {

score5P2 = true;

score4P2 = false;

gapP2 += 40;

}

if (score3P2) {

score4P2 = true;

score3P2 = false;

gapP2 += 40;

}

if (score2P2) {

score3P2 = true;

score2P2 = false;

gapP2 += 40;

}

if (score1P2) {

score2P2 = true;

score1P2 = false;

gapP2 += 40;

}

if (score0P2) {

score1P2 = true;

score0P2 = false;

gapP2 += 40;

}

}

if (directionx == -1) {

P1key = true;

P2key = false;

}

if (directionx == 1) {

P2key = true;

P1key = false;

}

if ((y >= height - radius) || (y <= 0)) {

directiony = -directiony;

}

x += speedx * directionx;

y += speedy * directiony;

if (x >= xP1)

if (x <= xP1 + 50)

if (y >= yP1)

if (y <= yP1 + RLengthP1) {

directionx = -directionx;

if (y <= yP1 + RLengthP1/2) {

directiony = -directiony;

}

speedx = speedx * 1.15;

speedy = speedy * 1.15;

fill(255);

rect(xP1, yP1, 40, RLengthP1);

}

if (x <= xP2 + 40)

if (x >= xP2 - 10)

if (y >= yP2)

if (y <= yP2 + RLengthP2) {

directionx = -directionx;

if (y <= yP2 + RLengthP2/2) {

directiony = -directiony;

}

speedx = speedx * 1.15;

speedy = speedy * 1.15;

fill(255);

rect(xP2, yP2, 40, RLengthP2);

}

}

if (intermediate) {

background(0);

if (score1P1) {

fill(255);

text ('9', gapP1, margin);

}

if (score2P1) {

fill(255);

text ('8', gapP1, margin);

}

if (score3P1) {

fill(255);

text ('7', gapP1, margin);

}

if (score4P1) {

fill(255);

text ('6', gapP1, margin);

}

if (score5P1) {

fill(255);

text ('5', gapP1, margin);

}

if (score6P1) {

fill(255);

text ('4', gapP1, margin);

}

if (score7P1) {

fill(255);

text ('3', gapP1, margin);

}

if (score8P1) {

fill(255);

text ('2', gapP1, margin);

}

if (score9P1) {

fill(255);

text ('1', gapP1, margin);

}

if (score10P1) {

fill(255);

text ('0', gapP1, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('2', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

if (score1P2) { // so score1P2 happens, then the text comes up for each time you score. the gap is the x that decides where

//the numbers are. the margin is the height (y-axis) for the numbers.

fill(255);

text ('9', gapP2, margin);

}

if (score2P2) {

fill(255);

text ('8', gapP2, margin);

}

if (score3P2) {

fill(255);

text ('7', gapP2, margin);

}

if (score4P2) {

fill(255);

text ('6', gapP2, margin);

}

if (score5P2) {

fill(255);

text ('5', gapP2, margin);

}

if (score6P2) {

fill(255);

text ('4', gapP2, margin);

}

if (score7P2) {

fill(255);

text ('3', gapP2, margin);

}

if (score8P2) {

fill(255);

text ('2', gapP2, margin);

}

if (score9P2) {

fill(255);

text ('1', gapP2, margin);

}

if (score10P2) {

fill(255);

text ('0', gapP2, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('1', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

fill(255);

rect(xP1, yP1, 40, lengthP1);

fill(255);

rect(xP2, yP2, 40, lengthP2);

fill(75);

ellipse(x, y, radius, radius);

if (yP1 > center) {

yP1 = yP1 - cdiff;

}

if (yP1 < center) {

yP1 = yP1 + cdiff;

}

if (yP2 > center) {

yP2 = yP2 - cdiff;

}

if (yP2 < center) {

yP2 = yP2 + cdiff;

}

if (P1key) {

if (keyPressed) {

if (key == 'a') {

yP1 = yP1 + ydiff;

}

if (key == 'q') {

yP1 = yP1 - ydiff;

}

}

}

if (P2key) {

if (keyPressed) {

if (key == 'l') {

yP2 = yP2 + ydiff;

}

if (key == 'o') {

yP2 = yP2 - ydiff;

}

}

}

yP1 = constrain(yP1, 0, height-RLengthP1);

yP2 = constrain(yP2, 0, height-RLengthP2);

if (x < -100) {

delay(1000);

x = 500;

y = 360;

speedx = 10;

speedy = 4;

directionx = -directionx;

RLengthP1 = 240;

if (score9P1) {

score10P1 = true;

score9P1 = false;

gapP1 -= 40;

}

if (score8P1) {

score9P1 = true;

score8P1 = false;

gapP1 -= 40;

}

if (score7P1) {

score8P1 = true;

score7P1 = false;

gapP1 -= 40;

}

if (score6P1) {

score7P1 = true;

score6P1 = false;

gapP1 -= 40;

}

if (score5P1) {

score6P1 = true;

score5P1 = false;

gapP1 -= 40;

}

if (score4P1) {

score5P1 = true;

score4P1 = false;

gapP1 -= 40;

}

if (score3P1) {

score4P1 = true;

score3P1 = false;

gapP1 -= 40;

}

if (score2P1) {

score3P1 = true;

score2P1 = false;

gapP1 -= 40;

}

if (score1P1) {

score2P1 = true;

score1P1 = false;

gapP1 -= 40;

}

if (score0P1) {

score1P1 = true;

score0P1 = false;

gapP1 -= 40;

}

}

if (x > 1100) {

delay(1000);

x = 500;

y = 360;

speedx = 10;

speedy = 4;

directionx = -directionx;

RLengthP2 = 240;

if (score9P2) {

score10P2 = true;

score9P2 = false;

gapP2 += 40;

}

if (score8P2) {

score9P2 = true;

score8P2 = false;

gapP2 += 40;

}

if (score7P2) {

score8P2 = true;

score7P2 = false;

gapP2 += 40;

}

if (score6P2) {

score7P2 = true;

score6P2 = false;

gapP2 += 40;

}

if (score5P2) {

score6P2 = true;

score5P2 = false;

gapP2 += 40;

}

if (score4P2) {

score5P2 = true;

score4P2 = false;

gapP2 += 40;

}

if (score3P2) {

score4P2 = true;

score3P2 = false;

gapP2 += 40;

}

if (score2P2) {

score3P2 = true;

score2P2 = false;

gapP2 += 40;

}

if (score1P2) {

score2P2 = true;

score1P2 = false;

gapP2 += 40;

}

if (score0P2) {

score1P2 = true;

score0P2 = false;

gapP2 += 40;

}

}

if (directionx == -1) {

P1key = true;

P2key = false;

}

if (directionx == 1) {

P2key = true;

P1key = false;

}

if ((y >= height - radius) || (y <= 0)) {

directiony = -directiony;

}

x += speedx * directionx;

y += speedy * directiony;

if (x >= xP1)

if (x <= xP1 + 50)

if (y >= yP1)

if (y <= yP1 + RLengthP1) {

directionx = -directionx;

if (y <= yP1 + RLengthP1/2) {

directiony = -directiony;

}

speedx = speedx * 1.15;

speedy = speedy * 1.15;

RLengthP2 *= 0.92;

fill(255);

rect(xP1, yP1, 40, RLengthP1);

}

if (x <= xP2 + 40)

if (x >= xP2 - 10)

if (y >= yP2)

if (y <= yP2 + RLengthP2) {

directionx = -directionx;

if (y <= yP2 + RLengthP2/2) {

directiony = -directiony;

}

speedx = speedx * 1.15;

speedy = speedy * 1.15;

RLengthP1 *= 0.92;

fill(255);

rect(xP2, yP2, 40, RLengthP2);

}

}

if (expert) {

background(0);

if (score1P1) {

fill(255);

text ('9', gapP1, margin);

}

if (score2P1) {

fill(255);

text ('8', gapP1, margin);

}

if (score3P1) {

fill(255);

text ('7', gapP1, margin);

}

if (score4P1) {

fill(255);

text ('6', gapP1, margin);

}

if (score5P1) {

fill(255);

text ('5', gapP1, margin);

}

if (score6P1) {

fill(255);

text ('4', gapP1, margin);

}

if (score7P1) {

fill(255);

text ('3', gapP1, margin);

}

if (score8P1) {

fill(255);

text ('2', gapP1, margin);

}

if (score9P1) {

fill(255);

text ('1', gapP1, margin);

}

if (score10P1) {

fill(255);

text ('0', gapP1, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('2', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

if (score1P2) {

fill(255);

text ('9', gapP2, margin);

}

if (score2P2) {

fill(255);

text ('8', gapP2, margin);

}

if (score3P2) {

fill(255);

text ('7', gapP2, margin);

}

if (score4P2) {

fill(255);

text ('6', gapP2, margin);

}

if (score5P2) {

fill(255);

text ('5', gapP2, margin);

}

if (score6P2) {

fill(255);

text ('4', gapP2, margin);

}

if (score7P2) {

fill(255);

text ('3', gapP2, margin);

}

if (score8P2) {

fill(255);

text ('2', gapP2, margin);

}

if (score9P2) {

fill(255);

text ('1', gapP2, margin);

}

if (score10P2) {

fill(255);

text ('0', gapP2, margin);

fill(255);

text ('P', 420, 600);

fill(255);

text ('1', 460, 600);

fill(255);

text ('W', 540, 600);

fill(255);

text ('I', 580, 600);

fill(255);

text ('N', 620, 600);

fill(255);

text ('S', 660, 600);

}

fill(255);

rect(xP1, yP1, 40, lengthP1);

fill(255);

rect(xP2, yP2, 40, lengthP2);

fill(15);

ellipse(x, y, radius, radius);

if (yP1 > center) {

yP1 = yP1 - cdiff;

}

if (yP1 < center) {

yP1 = yP1 + cdiff;

}

if (yP2 > center) {

yP2 = yP2 - cdiff;

}

if (yP2 < center) {

yP2 = yP2 + cdiff;

}

if (P1key) {

if (keyPressed) {

if (key == 'a') {

yP1 = yP1 + ydiff;

}

if (key == 'q') {

yP1 = yP1 - ydiff;

}

}

}

if (P2key) {

if (keyPressed) {

if (key == 'l') {

yP2 = yP2 + ydiff;

}

if (key == 'o') {

yP2 = yP2 - ydiff;

}

}

}

yP1 = constrain(yP1, 0, height-RLengthP1);

yP2 = constrain(yP2, 0, height-RLengthP2);

if (x < -100) {

delay(1000);

x = 500;

y = 360;

speedx = 10;

speedy = 4;

directionx = -directionx;

RLengthP1 = 240;

if (score9P1) {

score10P1 = true;

score9P1 = false;

gapP1 -= 40;

}

if (score8P1) {

score9P1 = true;

score8P1 = false;

gapP1 -= 40;

}

if (score7P1) {

score8P1 = true;

score7P1 = false;

gapP1 -= 40;

}

if (score6P1) {

score7P1 = true;

score6P1 = false;

gapP1 -= 40;

}

if (score5P1) {

score6P1 = true;

score5P1 = false;

gapP1 -= 40;

}

if (score4P1) {

score5P1 = true;

score4P1 = false;

gapP1 -= 40;

}

if (score3P1) {

score4P1 = true;

score3P1 = false;

gapP1 -= 40;

}

if (score2P1) {

score3P1 = true;

score2P1 = false;

gapP1 -= 40;

}

if (score1P1) {

score2P1 = true;

score1P1 = false;

gapP1 -= 40;

}

if (score0P1) {

score1P1 = true;

score0P1 = false;

gapP1 -= 40;

}

}

if (x > 1100) { // 1100 is the boundary line, so when X is past it, this occurs. the delay it makes the ball reset in the middle at x= 500 and //y=360

delay(1000);

x = 500;

y = 360;

speedx = 10; //this is the speed it resets to

speedy = 4;

directionx = -directionx; //this makes it so that the ball goes to the winner of the last volley by switching the x axis.

RLengthP2 = 240; // this resets the length of the loser's paddle

if (score9P2) {

score10P2 = true;

score9P2 = false;

gapP2 += 40;

}

if (score8P2) {

score9P2 = true;

score8P2 = false;

gapP2 += 40;

}

if (score7P2) {

score8P2 = true;

score7P2 = false;

gapP2 += 40;

}

if (score6P2) {

score7P2 = true;

score6P2 = false;

gapP2 += 40;

}

if (score5P2) {

score6P2 = true;

score5P2 = false;

gapP2 += 40;

}

if (score4P2) {

score5P2 = true;

score4P2 = false;

gapP2 += 40;

}

if (score3P2) {

score4P2 = true;

score3P2 = false;

gapP2 += 40;

}

if (score2P2) {

score3P2 = true;

score2P2 = false;

gapP2 += 40;

}

if (score1P2) {

score2P2 = true;

score1P2 = false;

gapP2 += 40;

}

if (score0P2) {

score1P2 = true;

score0P2 = false;

gapP2 += 40;

}

}

if (directionx == -1) { //This makes it so that when the x direction is negative, only player one can move their paddle by making

// player 2's paddle false.

P1key = true;

P2key = false;

}

if (directionx == 1) {//This makes it so that when the x direction is negative, only player two can move their paddle by making

// player 1's paddle false.

P2key = true;

P1key = false;

}

if ((y >= height - radius) || (y <= 0)) { // this makes the ball not go off the top of the screen. When the radius of the ball reaches the

// height of the screen it changes direction.

directiony = -directiony;

}

x += speedx * directionx;

y += speedy * directiony;

if (x >= xP1)

if (x <= xP1 + 50)

if (y >= yP1)

if (y <= yP1 + RLengthP1) {

directionx = -directionx; //This section flips the direction to make it seem like its bouncing off the wall.

if (y <= yP1 + RLengthP1/2) {

directiony = -directiony;

}

speedx = speedx * 1.15; //This is how the ball gets faster after every hit by 1.15 because the change direction aspect is above this

speedy = speedy * 1.15;

RLengthP2 *= 0.92;

fill(255);

rect(xP1, yP1, 40, RLengthP1);

}

if (x <= xP2 + 40)

if (x >= xP2 - 10)

if (y >= yP2)

if (y <= yP2 + RLengthP2) {

directionx = -directionx; //This just flips the way the ball moves on the x axis

if (y <= yP2 + RLengthP2/2) {

directiony = -directiony; //this just flips the way the ball moves on the y axis

}

speedx = speedx * 1.15; //This is how the ball gets faster after every hit by 1.15 because the change direction aspect is above this

speedy = speedy * 1.15;

RLengthP1 *= 0.92; //this is how the paddle gets smaller in expert and intermediate mode.

//the paddles length (y axis) is shortened by .92 of itself

fill(255);

rect(xP2, yP2, 40, RLengthP2); //

}

}

}

Some of the problems we had was that in the program we were using, only one thing can be controlled at a time. So while one player was moving, another one could press their button and prevent it from moving. Special thanks to Ken Yesh who suggested that when the ball is going in the positive direction, the right paddle can move and visa versa.

It was also a problem to put arduino into the program so we just used the key board instead.

Another problem was that when the ball first began to move, it would trace itself. We solved this by refreshing the screen everytime the ball moved so that is would just look like a ball moving.

If we had more time and money, we could have made it so the buttons you would have to press with your feet like a dance dance revolution pad. That or we would have had classes each having different abilities based on the amount of points in a row you get.