Ejemplo n.º 1
0
  public void init() {

    render =
        new Rectangle(
            (int)
                (pos.xPos
                    - pos.getWorldLocation().xPos
                    + pos.xPos
                    - renderDistanceWidth * 32 / 2
                    + width / 2),
            (int)
                (pos.yPos
                    - pos.getWorldLocation().yPos
                    + pos.yPos
                    - renderDistanceHeight * 32 / 2
                    + height / 2),
            renderDistanceWidth * 32,
            renderDistanceHeight * 32);

    listUp = new ArrayList<BufferedImage>();
    listDown = new ArrayList<BufferedImage>();
    listLeft = new ArrayList<BufferedImage>();
    listRight = new ArrayList<BufferedImage>();
    listIdle = new ArrayList<BufferedImage>();

    listUp.add(Assets.player.getTile(0, 32, 16, 16));
    listUp.add(Assets.player.getTile(16, 32, 16, 16));

    listDown.add(Assets.player.getTile(0, 16, 16, 16));
    listDown.add(Assets.player.getTile(16, 16, 16, 16));

    listRight.add(Assets.player.getTile(32, 16, 16, 16));
    listRight.add(Assets.player.getTile(32, 32, 16, 16));

    listLeft.add(Assets.player.getTile(48, 16, 16, 16));
    listLeft.add(Assets.player.getTile(48, 32, 16, 16));

    listIdle.add(Assets.player.getTile(0, 0, 16, 16));
    /*
    listIdle.add(Assets.player.getTile(16, 0, 16, 16));
    listIdle.add(Assets.player.getTile(32, 0, 16, 16));
    listIdle.add(Assets.player.getTile(48, 0, 16, 16));
    */

    // up
    ani_up = new Animator(listUp);
    ani_up.setSpeed(180);
    ani_up.play();
    // down
    ani_down = new Animator(listDown);
    ani_down.setSpeed(180);
    ani_down.play();
    // left
    ani_left = new Animator(listLeft);
    ani_left.setSpeed(180);
    ani_left.play();
    // right
    ani_right = new Animator(listRight);
    ani_right.setSpeed(180);
    ani_right.play();
    // idle
    ani_idle = new Animator(listIdle);
    ani_idle.setSpeed(180);
    ani_idle.play();
  }