Ejemplo n.º 1
0
  public void render(Graphics2D g) {
    g.fillRect((int) pos.xPos, (int) pos.yPos, width, height);

    if (animationState == 0) {
      g.drawImage(
          ani_up.sprite,
          (int) pos.xPos - width / 2,
          (int) pos.yPos - height,
          width * scale,
          height * scale,
          null);
      if (up) {
        ani_up.update(System.currentTimeMillis());
      }
    }
    if (animationState == 1) {
      g.drawImage(
          ani_down.sprite,
          (int) pos.xPos - width / 2,
          (int) pos.yPos - height,
          width * scale,
          height * scale,
          null);
      if (down) {
        ani_down.update(System.currentTimeMillis());
      }
    }
    if (animationState == 2) {
      g.drawImage(
          ani_right.sprite,
          (int) pos.xPos - width / 2,
          (int) pos.yPos - height,
          width * scale,
          height * scale,
          null);
      if (right) {
        ani_right.update(System.currentTimeMillis());
      }
    }
    if (animationState == 3) {
      g.drawImage(
          ani_left.sprite,
          (int) pos.xPos - width / 2,
          (int) pos.yPos - height,
          width * scale,
          height * scale,
          null);
      if (left) {
        ani_left.update(System.currentTimeMillis());
      }
    }
    if (animationState == 4) {
      g.drawImage(
          ani_idle.sprite,
          (int) pos.xPos - width / 2,
          (int) pos.yPos - height,
          width * scale,
          height * scale,
          null);
      ani_idle.update(System.currentTimeMillis());
    }

    g.drawRect(
        (int) pos.xPos - renderDistanceWidth * 32 / 2 + width / 2,
        (int) pos.yPos - renderDistanceHeight * 32 / 2 + height / 2,
        renderDistanceWidth * 32,
        renderDistanceHeight * 32);

    guiM.render(g);
    hudM.render(g);
  }