Exemplo n.º 1
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) {
      // EHSAN Brick Bump counter added here
      bricksBumped++;
      if (block == 1) {
        Mario.gainHiddenBlock();
      }
      bumpInto(x, y - 1);
      byte blockData = level.getBlockData(x, y);
      if (blockData < 0) {
        level.setBlockData(x, y, (byte) (blockData + 1));
      }

      if (blockData == 0) {
        level.setBlock(x, y, (byte) 4);
        level.setBlockData(x, y, (byte) 4);
      }

      if (((Level.TILE_BEHAVIORS[block & 0xff]) & Level.BIT_SPECIAL) > 0) {
        //        	System.out.println("2222");
        if (randomGen.nextInt(5) == 0 && level.difficulty > 4) {
          addSprite(new GreenMushroom(this, x * cellSize + 8, y * cellSize + 8));
          ++level.counters.greenMushrooms;
        } else {
          if (!Mario.large) {
            addSprite(new Mushroom(this, x * cellSize + 8, y * cellSize + 8));
            ++level.counters.mushrooms;
          } else {
            addSprite(new FireFlower(this, x * cellSize + 8, y * cellSize + 8));
            ++level.counters.flowers;
          }
        }
      } else {

        Mario.gainCoin();
        addSprite(new CoinAnim(x, y));
      }
    }

    if ((Level.TILE_BEHAVIORS[block & 0xff] & Level.BIT_BREAKABLE) > 0) {
      bumpInto(x, y - 1);
      if (canBreakBricks) {
        bricksBumped++;
        level.setBlock(x, y, (byte) 0);
        for (int xx = 0; xx < 2; xx++)
          for (int yy = 0; yy < 2; yy++)
            addSprite(
                new Particle(
                    x * cellSize + xx * 8 + 4,
                    y * cellSize + yy * 8 + 4,
                    (xx * 2 - 1) * 4,
                    (yy * 2 - 1) * 4 - 8));
      } else {
        level.setBlockData(x, y, (byte) 4);
      }
    }
  }
Exemplo n.º 2
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.gainCoin();
      level.setBlock(x, y, (byte) 0);
      addSprite(new CoinAnim(x, y + 1));
    }

    for (Sprite sprite : sprites) {
      sprite.bumpCheck(x, y);
    }
  }