how can you make a rocket move using the arrow keys
public void act() {
if (Greenfoot.isKeyDown("left")) {
turn(-5);
}
if (Greenfoot.isKeyDown("right")) {
turn(5);
}
if (Greenfoot.isKeyDown("up")) {
move(5);
}
if (Greenfoot.isKeyDown("down")) {
move(-5);
}
}
private void move(double distance) {
double angle = Math.toRadians(getRotation());
setLocation(getX() + (Math.cos(angle) * distance), getY() + (Math.sin(angle) * distance));
}