Search in sources :

Example 21 with SpriteTiled

use of com.b3dgs.lionengine.graphic.SpriteTiled in project lionengine by b3dgs.

the class MapTileRasteredModel method loadSheets.

/*
     * MapTileRastered
     */
@Override
public void loadSheets(Media rasterConfig, boolean smooth) {
    final Collection<Integer> sheets = map.getSheets();
    final Iterator<Integer> itr = sheets.iterator();
    final int th = map.getTileHeight();
    while (itr.hasNext()) {
        final Integer sheet = itr.next();
        final RasterImage raster = new RasterImage(map.getSheet(sheet).getSurface(), rasterConfig, th, smooth);
        raster.loadRasters(map.getTileHeight(), false, sheet.toString());
        final List<SpriteTiled> rastersSheet = getRasters(sheet);
        for (final ImageBuffer bufferRaster : raster.getRasters()) {
            final SpriteTiled sheetRaster = Drawable.loadSpriteTiled(bufferRaster, map.getTileWidth(), th);
            rastersSheet.add(sheetRaster);
        }
    }
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) RasterImage(com.b3dgs.lionengine.core.RasterImage)

Example 22 with SpriteTiled

use of com.b3dgs.lionengine.graphic.SpriteTiled in project lionengine by b3dgs.

the class MapTileRasteredModel method renderTile.

@Override
public void renderTile(Graphic g, MapTile map, Tile tile, int x, int y) {
    final Integer sheet = tile.getSheet();
    final int number = tile.getNumber();
    final SpriteTiled raster = getRasterSheet(sheet, getRasterIndex(tile.getInTileY()));
    raster.setLocation(x, y);
    raster.setTile(number);
    raster.render(g);
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled)

Example 23 with SpriteTiled

use of com.b3dgs.lionengine.graphic.SpriteTiled in project lionengine by b3dgs.

the class SpriteTiledTest method testEquals.

/**
 * Test equals.
 */
@Test
public void testEquals() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final SpriteTiled sprite = new SpriteTiledImpl(surface, 16, 8);
    final SpriteTiled spriteMedia = new SpriteTiledImpl(media, 16, 8);
    spriteMedia.load();
    Assert.assertEquals(sprite, sprite);
    Assert.assertEquals(sprite, new SpriteTiledImpl(surface, 16, 8));
    Assert.assertEquals(spriteMedia, spriteMedia);
    Assert.assertNotEquals(sprite, null);
    Assert.assertNotEquals(sprite, new Object());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(media, 16, 8));
    Assert.assertNotEquals(spriteMedia, new SpriteTiledImpl(media, 16, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(surface, 16, 16));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 32), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 64), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 64), 16, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 8, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 16));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 32), 8, 8));
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 64), 16, 16));
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 24 with SpriteTiled

use of com.b3dgs.lionengine.graphic.SpriteTiled in project lionengine by b3dgs.

the class SpriteTiledTest method testLoadMedia.

/**
 * Test load with media.
 */
@Test
public void testLoadMedia() {
    final SpriteTiled sprite = new SpriteTiledImpl(media, 16, 8);
    sprite.load();
    Assert.assertNotNull(sprite.getSurface());
    sprite.prepare();
    sprite.dispose();
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 25 with SpriteTiled

use of com.b3dgs.lionengine.graphic.SpriteTiled in project lionengine by b3dgs.

the class SpriteTiledTest method testMirror.

/**
 * Test mirror.
 */
@Test
public void testMirror() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    Assert.assertEquals(Mirror.NONE, sprite.getMirror());
    sprite.setMirror(Mirror.HORIZONTAL);
    Assert.assertEquals(Mirror.HORIZONTAL, sprite.getMirror());
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Aggregations

SpriteTiled (com.b3dgs.lionengine.graphic.SpriteTiled)31 Test (org.junit.Test)24 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)6 LionEngineException (com.b3dgs.lionengine.LionEngineException)1 Media (com.b3dgs.lionengine.Media)1 RasterImage (com.b3dgs.lionengine.core.RasterImage)1 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)1 TileRef (com.b3dgs.lionengine.game.feature.tile.TileRef)1 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1