Search in sources :

Example 6 with SpriteTiled

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

the class SpriteTiledTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
public void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final SpriteTiled sprite = new SpriteTiledImpl(surface, 16, 8);
    Assert.assertTrue(sprite.isLoaded());
    Assert.assertEquals(surface, sprite.getSurface());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    Assert.assertEquals(16, sprite.getTileWidth());
    Assert.assertEquals(8, sprite.getTileHeight());
    Assert.assertEquals(4, sprite.getTilesHorizontal());
    Assert.assertEquals(4, sprite.getTilesVertical());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 7 with SpriteTiled

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

the class SpriteTiledTest method testSetTileInvalid.

/**
 * Set set tile with invalid value.
 */
@Test(expected = LionEngineException.class)
public void testSetTileInvalid() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setTile(-1);
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 8 with SpriteTiled

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

the class SpriteTiledTest method testFilterNull.

/**
 * Test filter.
 */
@Test(expected = LionEngineException.class)
public void testFilterNull() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.filter(null);
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 9 with SpriteTiled

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

the class SpriteTiledTest method testSetTransparency.

/**
 * Test set transparency.
 */
@Test
public void testSetTransparency() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setTransparency(ColorRgba.BLACK);
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 10 with SpriteTiled

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

the class SpriteTiledTest method testHashCode.

/**
 * Test hash code.
 */
@Test
public void testHashCode() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final int sprite = new SpriteTiledImpl(surface, 16, 8).hashCode();
    final SpriteTiled spriteMedia = new SpriteTiledImpl(media, 16, 8);
    spriteMedia.load();
    Assert.assertEquals(sprite, new SpriteTiledImpl(surface, 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new Object().hashCode());
    Assert.assertNotEquals(spriteMedia.hashCode(), new SpriteTiledImpl(media, 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 32), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 64), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 64), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 8, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 16).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(32, 32), 8, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteTiledImpl(Graphics.createImageBuffer(64, 64), 16, 16).hashCode());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) 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