In my crab game, the crab only moves forwards. I was wondering if it is possible to also make it move backwards. This is the code used to allow the crab to move forwards:
private static final double WALKING_SPEED = 5.0;
public void move()
{
double angle = Math.toRadians( getRotation() );
int x = (int) Math.round(getX() + Math.cos(angle) * WALKING_SPEED);
int y = (int) Math.round(getY() + Math.sin(angle) * WALKING_SPEED);
setLocation(x, y);
}
Please help and explain! Thank you! :D

