Exemplo n.º 1
0
 private synchronized void createLevel(String levelPath, GameMode mode) {
   LevelInformation li = LevelInformation.getInfoForPath(levelPath);
   if (li != null) {
     createLevel(li, mode);
     return;
   } else if (!isMultiplayer) {
     showError("Missing map.");
   }
   showError("Missing map - Multiplayer");
 }
Exemplo n.º 2
0
  private void openLevel(LevelInformation li) {
    BufferedImage bufferedImage = null;

    try {
      if (li.vanilla) {
        bufferedImage = ImageIO.read(MojamComponent.class.getResource(li.getPath()));
      } else {
        bufferedImage = ImageIO.read(new File(li.getPath()));
      }
    } catch (IOException ioe) {
    }

    int w = bufferedImage.getWidth();
    int h = bufferedImage.getHeight();

    int[] rgbs = new int[w * h];

    bufferedImage.getRGB(0, 0, w, h, rgbs, 0, w);

    newLevel();

    removeText(levelName);
    levelName = new Text(1, li.levelName, 120, 5);
    addText(levelName);

    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        int col = rgbs[x + y * w] & 0xffffffff;
        // loadColorTile(col, x, y);

        IEditable tile = LevelUtils.getNewTileFromColor(col);
        draw(tile, x, y);

        if (tile instanceof FloorTile) {

          Entity entity = LevelUtils.getNewEntityFromColor(col, x, y);
          if (entity instanceof IEditable) {
            draw((IEditable) entity, x, y);
          }
        }
      }
    }
  }