Search in sources :

Example 26 with SpriteTiled

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

the class SpriteTiledTest method testStretchInvalidWidth.

/**
 * Test stretch sprite with invalid width.
 */
@Test(expected = LionEngineException.class)
public void testStretchInvalidWidth() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.stretch(0.0, 100.0);
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 27 with SpriteTiled

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

the class SpriteTiledTest method testSetAlphaLow.

/**
 * Test set alpha too low.
 */
@Test(expected = LionEngineException.class)
public void testSetAlphaLow() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setAlpha(-1);
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 28 with SpriteTiled

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

the class SpriteTiledTest method testSetAlpha.

/**
 * Test set alpha.
 */
@Test
public void testSetAlpha() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    for (int alpha = 0; alpha < 256; alpha++) {
        sprite.setAlpha(alpha);
        Assert.assertEquals(64, sprite.getWidth());
        Assert.assertEquals(32, sprite.getHeight());
    }
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 29 with SpriteTiled

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

the class SpriteTiledTest method testLoadMediaAlready.

/**
 * Test load with media already loaded.
 */
@Test(expected = LionEngineException.class)
public void testLoadMediaAlready() {
    final SpriteTiled sprite = new SpriteTiledImpl(media, 16, 8);
    sprite.load();
    sprite.load();
}
Also used : SpriteTiled(com.b3dgs.lionengine.graphic.SpriteTiled) Test(org.junit.Test)

Example 30 with SpriteTiled

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

the class SpriteTiledTest method testStretch.

/**
 * Test stretch sprite.
 */
@Test
public void testStretch() {
    final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.stretch(100.0, 100.0);
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    Assert.assertEquals(16, sprite.getTileWidth());
    Assert.assertEquals(8, sprite.getTileHeight());
    sprite.stretch(200.0, 100.0);
    Assert.assertEquals(128, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    Assert.assertEquals(32, sprite.getTileWidth());
    Assert.assertEquals(8, sprite.getTileHeight());
    sprite.stretch(100.0, 200.0);
    Assert.assertEquals(128, sprite.getWidth());
    Assert.assertEquals(64, sprite.getHeight());
    Assert.assertEquals(32, sprite.getTileWidth());
    Assert.assertEquals(16, sprite.getTileHeight());
    sprite.stretch(200.0, 200.0);
    Assert.assertEquals(256, sprite.getWidth());
    Assert.assertEquals(128, sprite.getHeight());
    Assert.assertEquals(64, sprite.getTileWidth());
    Assert.assertEquals(32, sprite.getTileHeight());
}
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