Just need someone to help me figure out whats wrong with this code the Ball keeps getting stuck in the top right corner
int xBall, yBall;
int xMoveVal = 5;
int yMoveVal = 5;
/**
* Act - do whatever the Ball wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
xBall = getX();
yBall = getY();
setLocation(xBall + xMoveVal, yBall - yMoveVal);
if (yBall < 10)
{
yMoveVal*=-1;
}
if (xBall > getWorld().getWidth())
{
xMoveVal*=-1;
}
if (yBall > getWorld().getHeight())
{
yMoveVal*=-1;
}
if (xBall < 0)
{
xMoveVal*=-1;
}
if (isTouching(Paddle.class))
{
xMoveVal*=-1;
}
}
}
