Search in sources :

Example 11 with SpriteTiled

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;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteTiled(com.b3dgs.lionengine.graphic.drawable.SpriteTiled) RasterImage(com.b3dgs.lionengine.graphic.raster.RasterImage)

Example 12 with SpriteTiled

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));
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.drawable.SpriteTiled) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) Test(org.junit.jupiter.api.Test)

Aggregations

SpriteTiled (com.b3dgs.lionengine.graphic.drawable.SpriteTiled)12 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)5 Media (com.b3dgs.lionengine.Media)3 ArrayList (java.util.ArrayList)2 Surface (com.b3dgs.lionengine.Surface)1 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)1 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)1 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1 RasterImage (com.b3dgs.lionengine.graphic.raster.RasterImage)1 Test (org.junit.jupiter.api.Test)1