I am not completely for sure as to how to go about this step, but I have what I have attempted. My teacher said I needed to use revertVertical and revertHorizontal. I also have code to change the color of an object when it hits an object of the same class, but it turns them all black and not a random color.
game with full source
public void colorChange() { List<Body> bodies = getIntersectingObjects(Body.class); for(Body b : bodies) { int h = b.getImage().getHeight(); GreenfootImage x = new GreenfootImage(h,h); Color c = new Color(Greenfoot.getRandomNumber(256), Greenfoot.getRandomNumber(256), Greenfoot.getRandomNumber(256)); x.fillOval(0,0,h-1,h-1); b.setImage(x); } } public void bounce() { if(getX() == 0 || getX() == 920) { if(getY() == 0 || getY() == 640) { getMovement().revertVertical(); getMovement().revertHorizontal(); } } }