Ejemplo n.º 1
0
  public void move() {
    if (deadTime > 0) {
      deadTime--;

      if (deadTime == 0) {
        deadTime = 1;
        for (int i = 0; i < 8; i++) {
          world.addSprite(
              new Sparkle(
                  (int) (x + Math.random() * 16 - 8) + 4,
                  (int) (y - Math.random() * 8) + 4,
                  (float) (Math.random() * 2 - 1),
                  (float) Math.random() * -1,
                  0,
                  1,
                  5));
        }
        spriteContext.removeSprite(this);
      }

      x += xa;
      y += ya;
      ya *= 0.95;
      ya += 1;

      return;
    }

    tick++;

    if (y >= yStart) {
      y = yStart;

      int xd = (int) (Math.abs(world.mario.x - x));
      jumpTime++;
      if (jumpTime > 40 && xd > 24) {
        ya = -8;
      } else {
        ya = 0;
      }
    } else {
      jumpTime = 0;
    }

    y += ya;
    ya *= 0.9;
    ya += 0.1f;

    xPic = ((tick / 2) & 1) * 2 + ((tick / 6) & 1);
  }