My problem is that when ever the ball come to the left paddle which is controlled by the mouse it just passes through it even though im pretty sure the code i have inserted shuld, i have the same code for the paddle on the right and it works perfectly. Any help is great;y appreciated, Thanks
int radius = 25;
float xp, yp;
float velocityX = 1;
float velocityY = 2;
int xdirection = 1;
int ydirection = 1;
int rpX = 585;
int rpY = height/2;
int velocityRP = 5;
int lpX1 = 15;
int lpY1 = mouseY;
void setup()
{
size(600, 400);
noStroke();
smooth();
rectMode(CENTER);
ellipseMode(CENTER);
xp = width/2;
yp = height/2;
}
void draw()
{
background(175);
Bbounce();
RP();
LP();
}
void Bbounce()
{
xp = xp + (velocityX * xdirection); //ball movement
yp = yp + (velocityY * ydirection);
if(xp > width + radius)
{
xp = width/2;
yp = height/2;
velocityY = 2;
velocityX =1;
xdirection = -1;
ydirection = 1;
}
if(xp < 0)
{
xp = width/2;
yp = height/2;
velocityY = 2;
velocityX =1;
xdirection = 1;
ydirection = 1;
}
if(yp > height - radius/2 || yp < radius/2) //ball bouncing off top and bottem of screen
{
ydirection = ydirection * -1;
}
if(yp > rpY - 35 && yp < rpY + 35) //bal bouncing off right paddle