Exemple #1
0
  public void bumpInto(int x, int y) {
    byte block = level.getBlock(x, y);
    if (((Level.TILE_BEHAVIORS[block & 0xff]) & Level.BIT_PICKUPABLE) > 0) {
      Mario.getCoin();
      sound.play(
          Art.samples[Art.SAMPLE_GET_COIN], new FixedSoundSource(x * 16 + 8, y * 16 + 8), 1, 1, 1);
      level.setBlock(x, y, (byte) 0);
      addSprite(new CoinAnim(x, y + 1));

      // TODO no idea when this happens... maybe remove coin count
      if (recorder != null) recorder.recordCoin();
    }

    for (Sprite sprite : sprites) {
      sprite.bumpCheck(x, y);
    }
  }
Exemple #2
0
  public void bump(int x, int y, boolean canBreakBricks) {
    byte block = level.getBlock(x, y);

    if ((Level.TILE_BEHAVIORS[block & 0xff] & Level.BIT_BUMPABLE) > 0) {
      bumpInto(x, y - 1);
      level.setBlock(x, y, (byte) 4);

      if (((Level.TILE_BEHAVIORS[block & 0xff]) & Level.BIT_SPECIAL) > 0) {
        sound.play(
            Art.samples[Art.SAMPLE_ITEM_SPROUT],
            new FixedSoundSource(x * 16 + 8, y * 16 + 8),
            1,
            1,
            1);
        if (!Mario.large) {
          addSprite(new Mushroom(this, x * 16 + 8, y * 16 + 8));
        } else {
          addSprite(new FireFlower(this, x * 16 + 8, y * 16 + 8));
        }

        if (recorder != null) {
          recorder.blockPowerDestroyRecord();
        }
      } else {
        // TODO should only record hidden coins (in boxes)
        if (recorder != null) {
          recorder.blockCoinDestroyRecord();
        }

        Mario.getCoin();
        sound.play(
            Art.samples[Art.SAMPLE_GET_COIN],
            new FixedSoundSource(x * 16 + 8, y * 16 + 8),
            1,
            1,
            1);
        addSprite(new CoinAnim(x, y));
      }
    }

    if ((Level.TILE_BEHAVIORS[block & 0xff] & Level.BIT_BREAKABLE) > 0) {
      bumpInto(x, y - 1);
      if (canBreakBricks) {
        if (recorder != null) {
          recorder.blockEmptyDestroyRecord();
        }

        sound.play(
            Art.samples[Art.SAMPLE_BREAK_BLOCK],
            new FixedSoundSource(x * 16 + 8, y * 16 + 8),
            1,
            1,
            1);
        level.setBlock(x, y, (byte) 0);
        for (int xx = 0; xx < 2; xx++)
          for (int yy = 0; yy < 2; yy++)
            addSprite(
                new Particle(
                    x * 16 + xx * 8 + 4,
                    y * 16 + yy * 8 + 4,
                    (xx * 2 - 1) * 4,
                    (yy * 2 - 1) * 4 - 8));
      }
    }
  }