Hi i am pretty new and i need a code to meke my boss move alone whitout pressing any key can someone help
public void act() { move(); shoot(); } private void move() { move(1); } public void shoot() { // code omitted (see below) }
int yDir = 1; int speed = 1; // adjust as required public void act() { move(); turnAround(); shoot(); } private void move() { setLocation(getX(), getY()+speed*yDir); } private void turnAround() { int halfHeight = getImage().getHeight()/2; if ((getY() < halfHeight && yDir < 0) || (getY() > getWorld().getHeight()-halfHeight && yDir > 0)) yDir = -yDir; } // etc.