@Before public void setUp() { GlobalConstants.setUp(); tilemap = new TileMap(32); tilemap.loadMap("/Maps/level1map.map"); tilemap.loadTiles("/Tilesets/tileset.png"); }
/** 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"); } }
/** 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."); } }