use of com.b3dgs.lionengine.game.feature.tile.TilesExtractor in project lionengine by b3dgs.
the class Scene method load.
@Override
public void load() {
final Media levelrip = Medias.create("level.png");
final TilesExtractor tilesExtractor = new TilesExtractor();
final AtomicInteger p = new AtomicInteger();
tilesExtractor.addListener((percent, tiles) -> p.set(percent));
Collection<ImageBuffer> buffers = tilesExtractor.extract(16, 16, Arrays.asList(levelrip));
map.loadSheets(SheetsExtractor.extract(buffers, 16));
buffers.forEach(ImageBuffer::dispose);
assertEquals(100, p.get());
p.set(0);
tilesExtractor.addListener((percent, tiles) -> p.set(percent));
buffers = tilesExtractor.extract(() -> true, 16, 16, Arrays.asList(levelrip));
map.loadSheets(SheetsExtractor.extract(buffers, 16));
buffers.forEach(ImageBuffer::dispose);
assertEquals(0, p.get());
tilesExtractor.addListener((percent, tiles) -> p.set(percent));
buffers = tilesExtractor.extract(() -> false, 16, 16, Arrays.asList(levelrip));
map.loadSheets(SheetsExtractor.extract(buffers, 16));
buffers.forEach(ImageBuffer::dispose);
assertEquals(100, p.get());
p.set(0);
LevelRipConverter.start(levelrip, map, (percent, progressTileX, progressTileY) -> p.set(percent));
assertEquals(100, p.get());
mapViewer.prepare(map);
minimap.load();
minimap.automaticColor();
minimap.prepare();
camera.setView(0, 0, getWidth(), getHeight(), getHeight());
camera.setLimits(map);
tick.start();
}
use of com.b3dgs.lionengine.game.feature.tile.TilesExtractor in project lionengine by b3dgs.
the class MapTileGame method create.
/**
* Create a map from a level rip which should be an image file (*.PNG, *.BMP) that represents the full map.
* The file will be read pixel by pixel to recognize tiles and their location. Data structure will be created (
* {@link #create(int, int, int, int)}).
*
* @param levelrip The file describing the levelrip as a single image.
* @param tileWidth The tile width.
* @param tileHeight The tile height.
* @param horizontalTiles The number of horizontal tiles on sheets.
* @throws LionEngineException If error when importing map.
* @see TilesExtractor
* @see LevelRipConverter
*/
public void create(Media levelrip, int tileWidth, int tileHeight, int horizontalTiles) {
final TilesExtractor tilesExtractor = new TilesExtractor();
final Collection<ImageBuffer> buffers = tilesExtractor.extract(tileWidth, tileHeight, Arrays.asList(levelrip));
loadSheets(SheetsExtractor.extract(buffers, horizontalTiles));
for (final ImageBuffer tileBuffer : buffers) {
tileBuffer.dispose();
}
LevelRipConverter.start(levelrip, mapSurface);
}
Aggregations