public void update() {
    if (moveDir == 0) {
      move(0, -1);
      currentAnimationIndex = new int[] { 0, 1 };
    } else if (moveDir == 1) {
      move(1, 0);
      currentAnimationIndex = new int[] { 2, 3 };
    } else if (moveDir == 2) {
      move(0, 1);
      currentAnimationIndex = new int[] { 4, 5 };
    } else if (moveDir == 3) {
      move(-1, 0);
      currentAnimationIndex = new int[] { 6, 7 };
    }
    if (isHit()) {
      health--;
      isHit = false;
    }
    if (health == 0) {
      removed = true;
    }
    if (System.currentTimeMillis() - lastTime >= (animationLength * 1000D)) {
      switchRenderSprite();
      lastTime = System.currentTimeMillis();
    }
  }