From another forum , I found code for bouncing off walls at an equal and opposite angle, however, the code is incomplete and I cannot work it out for the top and left walls. this is what I have:
Please help and thanks in advance.
public void bounceoffwall()
{
if (isAtEdge())
{
if (getY() == 0 || getY() == getWorld().getHeight()-1) /**bottom*/
{
setRotation(360-getRotation());
}
if (getX()==0 || getX() == getWorld().getWidth()-1) /**right*/
{
setRotation(180-getRotation());
}
if (getY() == 0) /**top*/
{
setRotation(int-getRotation());
}
if (getX() == 0) /**left*/
{
setRotation(int-getRotation());
}
//left edge: getX() == 0
//right edge: getX() == getWorld().getWidth()-1
//top edge: getY() == 0
//bottom edge: getY() == getWorld().getHeight()-1
}
}

