Пример #1
0
 @Before
 public void setUp() {
   GlobalConstants.setUp();
   tilemap = new TileMap(32);
   tilemap.loadMap("/Maps/level1map.map");
   tilemap.loadTiles("/Tilesets/tileset.png");
 }
Пример #2
0
  /** Lataa tiilit kartalta muistiin. */
  public void loadTiles(String s) {
    try {
      tileset = ImageIO.read(getClass().getResourceAsStream(s));
      numberOfTilesPerRow = tileset.getWidth() / tileSize;
      tiles = new Tile[2][numberOfTilesPerRow];
      setTiles();

    } catch (IOException e) {
      GlobalConstants.error("An error occured while trying to load tiles. Teminating");
    }
  }
Пример #3
0
  /** Lataa karttatiedoston muistiin. */
  public void loadMap(String s) {
    try {
      InputStream in = getClass().getResourceAsStream(s);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      numberofColumns = Integer.parseInt(br.readLine());
      numberOfRows = Integer.parseInt(br.readLine());
      setMapAttributes();
      setUpMap(br);

    } catch (IOException | NumberFormatException e) {
      GlobalConstants.error("An error occured while loading mapfile. Terminating.");
    }
  }