#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

#### In this Discussion

edited August 2017

So im making a pong game and i have the code for the Right paddle to have the ball get bounced off. Then i copied that code and made some changes for it to "work" for the left paddle. Then i removed the collision for the left and right walls to see if the left paddle worked but i guess it was not. But im not sure what i did wrong. Any help would be great!

``````float x = 300;
float y = 300;
float velocityX = 2;
float velocityY = 3;
////////////////////
////////////////////
float ai;

void setup() {
size(600,680);
}

void draw() {
x += velocityX;
y += velocityY;

background(20);
noStroke();
fill(255);
rect(x,y,20,20);
fill(100);
strokeWeight(2);
stroke(255);
rect(-1,0,601,80);
rect(-1,600,601,80);
//println(player);
//println(ballY);
ai = y-50;

if (x <= -20) {
x = 100;
y = 100;
} else if (x >= 600) {
x = 100;
y = 100;
}

/*if (x > 580 || x < 0) {
velocityX *= -1;
}*/
if (y > 580 || y < 80) {
velocityY *= -1;
}

velocityX /= -1;

}

velocityX /= -1;

}
}
``````
Tagged: