Esempio n. 1
0
  @Override
  public void update() {
    test.update();
    if (reloadSpeed > 0) {
      reloadSpeed--;
    }
    int xa = 0, ya = 0;

    if (animation < 7500) {
      animation++;
    } else {
      animation = 0;
    }

    if (input.up) {
      ya--;
    }
    if (input.down) {
      ya++;
    }
    if (input.left) {
      xa--;
    }
    if (input.right) {
      xa++;
    }
    if (xa != 0 || ya != 0) {
      move(xa, ya);
      walking = true;
    } else {
      walking = false;
    }
    clear();
    updateShooting();
  }
Esempio n. 2
0
  @Override
  public void render(Screen screen) {

    if (direction == 0) {
      sprite = Sprite.player_back;
      if (walking) {
        if (animation % 20 > 10) {
          sprite = Sprite.player_back_1;
        } else {
          sprite = Sprite.player_back_2;
        }
      }
    }
    if (direction == 1) {
      sprite = Sprite.player_left;
      if (walking) {
        if (animation % 20 > 10) {
          sprite = Sprite.player_left_1;
        } else {
          sprite = Sprite.player_left_2;
        }
      }
    }
    if (direction == 2) {
      sprite = Sprite.player_front;
      if (walking) {
        if (animation % 20 > 10) {
          sprite = Sprite.player_front_1;
        } else {
          sprite = Sprite.player_front_2;
        }
      }
    }
    if (direction == 3) {
      sprite = Sprite.player_right;
      if (walking) {
        if (animation % 20 > 10) {
          sprite = Sprite.player_right_1;
        } else {
          sprite = Sprite.player_right_2;
        }
      }
    }

    sprite = test.getSprite();
    screen.renderDoubleTile(x - 16, y - 16, sprite);
  }