Your next step is to account for a collision with the walls. You will accomplish this within a method called turnIfNeeded(), which will be called from the act() method of Orb. The turnIfNeeded() method may call four seperate methods, which you will write within this step. Here iis the code for turnAtFloor(). Use it as a model to create the other three methods.
public void turnAtFloor()
{
if (getY() + getImage().getHeight()/2 >= getWorld().getHeight() ) {
vel.reverseY();
I got the code for turnAtRightWall(), its the rest I'm stumped on. Anyone with some help would be greatly appreaciated
/**
* makes the Orb bounce off the edge of the world on all four sides,
* not just hit the edge and turn.
*/
public void turnAtFloor()
{
if (getY() + getImage().getHeight()/2>=getWorld().getHeight() ) {
vel.reverseY();
}
}
public void turnAtRightWall()
{
if (getX() + getImage().getWidth()/2>=getWorld().getWidth() ) {
vel.reverseX();
}
}
public void turnAtRoof()
{
if (getY() + getImage().getHeight()/2<=getWorld().getHeight() ) {
vel.reverseY();
}
}
public void turnAtLeftWall()
{
if (getX() + getImage().getWidth()/2<=getWorld().getWidth() ) {
vel.reverseX();
}
}

