Hello, I have been trying to make a body bounce when bouncing off an edge in Newton's Lab 3. This is to make multiple enities when they touch the edge, change colour. Here is the current code:
private void bounceAtEdge()
{
if (getX() == 0 || getX() == getWorld().getWidth()-1) {
setLocation((double)getX(), (double)getY());
getMovement().revertHorizontal();
accelerate(0.9);
changeColor()
}
else if (getY() == 0 || getY() == getWorld().getHeight()-1){
setLocation((double)getX(), (double)getY());
getMovement().revertVertical();
accelerate(0.9);
changeColor()
}
}
public void changeColor()
{
int g = Greenfoot.getRandomNumber(255);
int r = Greenfoot.getRandomNumber(255);
int b = Greenfoot.getRandomNumber(255);
image.setColor (color);
}
/**

