* @return
* @throws IOException
*/
protected TileSet buildTileset(int id, Project p) throws IOException {
// load tileset
CTileset ct = (CTileset) p.getObjects().get("tileset").getObjects().get(id);
// build tileset
TileSet tileset = new TileSet();
BufferedImage b = ct.getTilesetGraphic(p);
// add tileset
// add tiles
for (int i = 0, l = b.getWidth() / 32 * (b.getHeight() / 32); i < l; i++) {
Tile t = new Tile();
t.setId(i);
t.setImage(b.getSubimage(i % (b.getWidth() / 32) * 32, i / (b.getWidth() / 32) * 32, 32, 32));
t.setTileSet(tileset);
tileset.addTile(t);
}
tileset.setName(ct.getTitle());
return tileset;
}