i was test collision between ball and box. i have a ball and long rect(platform) on screen. the collision part works fine. but i want to test where the ball is touch the platform. so if ball touch the ball from left or right or top or bottom. but when i run this. but it is not seem to be going in any of the inner if statments.
x = ball x
y = ball y
radius = ball width and height
rx = rect x
ry = rect y
rheight = rect height
rwidth = rect width
main game loop:
x += dx; //keep the ball moving so i can test the collision
y += dy;
//collsion between ball and box
if(x+radius > rx && x < rx+rwidth)
{
if(y+radius > ry && y < ry+rheight)
{
if(y+radius == ry)
{
System.out.println("top");
}
else if(y == ry+rheight)
{
System.out.println("bottom");
}
else if(x+radius == rx)
{
System.out.println("left");
}
else if(x == rx+rwidth)
{
System.out.println("right");
}
}
}