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);
      }
    }
  }
示例#2
0
  public void mouseDragged(MouseEvent e) {
    xTile = e.getX() / 16;
    yTile = e.getY() / 16;

    level.setBlock(xTile, yTile, tilePicker.pickedTile);
    levelRenderer.repaint(xTile - 1, yTile - 1, 3, 3);

    repaint();
  }
  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);
    }
  }
示例#4
0
  public void mousePressed(MouseEvent e) {
    xTile = e.getX() / 16;
    yTile = e.getY() / 16;

    if (e.getButton() == 3) {
      tilePicker.setPickedTile(level.getBlock(xTile, yTile));
    } else {
      level.setBlock(xTile, yTile, tilePicker.pickedTile);
      levelRenderer.repaint(xTile - 1, yTile - 1, 3, 3);

      repaint();
    }
  }