//int creates variables
//boolean creates false/true option
//color sets color for item
int x, y, w, h, speedX, speedY;
int paddleXL, paddleYL, paddleW, paddleH, paddleS;
int paddleXR, paddleYR;
boolean upL, downL;
boolean upR, downR;
//colorL and colorR are not needed, but it can be helpful
color colorL = color(255,0,0);
color colorR = color(0, 255, 0, 50);
//scoreL is for left score and scoreR is for the right score
int scoreL = 0;
int scoreR = 0;
//this sets the final winScore to a count of 10
int winScore = 10;
//Sets the game and window size up, along with the background and other important things
//happens only once; at the beginning of the game
void setup() {
//this sets the window size
size(500, 500);
//the x,y,w,h get the ball to begin at the center of the game
x = width/2;
y = height/2;
w = 50;
h = 50;
//this allows the ball to bounce
speedX = 4;
speedY = 4;
//this creates a text
textSize(30);
textAlign(CENTER, CENTER); //this centers the height and width of the text
rectMode(CENTER); //this allows both paddles to be centered
//This sets the paddles to a certain place on the window, and makes them visible
paddleXL = 40;
paddleYL = height/2;
paddleXR = width-40;
paddleYR = height/2;
paddleW = 30;
paddleH = 100;
paddleS = 5;
}
//Draws the canvas for the game
void draw() {
background(0);
drawCircle();
moveCircle();
bounceOff();
drawPaddles();
movePaddle();
restrictPaddle();
contactPaddle();
scores();
gameOver();
}
//creates paddles
void drawPaddles() {
YOU ARE READING
JavaScript Coding
RandomHello, world! So to start this off I'm not the best writer. However, if you enjoy programing or just video games (and fails) in general then you're in the right place. This is sort of a book I will occasionally post on since coming up with these is...
