Ok I have this code to test colision of 4 “bars” to the ball.
public void checkHBarColision1(){
if(ballX <= hBarX+hBarW && ballX >= hBarX && ballY <= hBar1Y+hBarH){
//if(ballDir==3 || ballDir==0)
bounceDown();
}
}
public void checkHBarColision2(){
if(ballX <= hBarX+hBarW && ballX >= hBarX && ballY+16 >= hBar2Y-hBarH){
////if(ballDir==5 || ballDir==2)
bounceUp();
}
}
public void checkVBarColision1(){
if(ballY <= vBarY+vBarH && ballY >= vBarY && ballX <= vBarY+vBarW){
//if(ballDir >= 3)
bounceRight();
}
}
public void checkVBarColision2(){
if(ballY <= vBarY+vBarH && ballY >= vBarY && ballX+16 >= vBarY-vBarW){
//if(ballDir <= 2)
bounceRight();
}
}
Now what controles all four bars(2 on the top and bottom of the screen,2 on left and right.) is the mouse. mouse Y position dictates the Y position of the Verticle(sides) and the X position of the mouse dictates the x position of the horizontal bars(top and bottom). Now the ball only bounces when the mouse has touchted the ball. Any idea why the ball bounces when it touches the location of the mouse, and not the bars?