use of com.b3dgs.lionengine.graphic.drawable.SpriteTiled in project lionengine by b3dgs.
the class MapTileRasteredModel method loadSheets.
@Override
public boolean loadSheets() {
if (raster == null || !raster.exists()) {
return false;
}
final int th = map.getTileHeight();
final int sheetsCount = map.getSheetsNumber();
for (int sheetId = 0; sheetId < sheetsCount; sheetId++) {
final Integer sheet = Integer.valueOf(sheetId);
final RasterImage rasterImage = new RasterImage(map.getSheet(sheetId).getSurface(), raster, th);
rasterImage.loadRasters(true, sheet.toString());
count = -1;
final List<SpriteTiled> rastersSheet = getRasters(sheet);
for (final ImageBuffer bufferRaster : rasterImage.getRasters()) {
final SpriteTiled sheetRaster = Drawable.loadSpriteTiled(bufferRaster, map.getTileWidth(), th);
rastersSheet.add(sheetRaster);
count++;
}
}
return true;
}
use of com.b3dgs.lionengine.graphic.drawable.SpriteTiled in project lionengine by b3dgs.
the class MapTileGameTest method testSetGetTile.
/**
* Test map set and get tile.
*/
@Test
void testSetGetTile() {
map.create(16, 16, 3, 3);
map.loadSheets(new ArrayList<SpriteTiled>());
assertEquals(0, map.getTilesNumber());
assertNull(map.getTile(0, 0));
assertNull(map.getTileAt(51.0, 68.0));
map.setTile(0, 0, 0);
final Tile tile = map.getTile(0, 0);
assertEquals(1, map.getTilesNumber());
assertEquals(tile, map.getTile(0, 0));
assertEquals(tile, map.getTile(Geom.createLocalizable(0, 0), 0, 0));
assertEquals(tile, map.getTileAt(3.0, 6.0));
assertEquals(Arrays.asList(tile), map.getTilesHit(-1, -1, 1, 1));
}
Aggregations