Search in sources :

Example 1 with Sprite

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

the class SpriteTest method testConstructorMedia.

/**
 * Test constructor with media.
 */
@Test
public void testConstructorMedia() {
    final Sprite sprite = new SpriteImpl(media);
    Assert.assertFalse(sprite.isLoaded());
    Assert.assertNull(sprite.getSurface());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 2 with Sprite

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

the class SpriteTest method testEquals.

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

Example 3 with Sprite

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

the class SpriteTest method testSetFade.

/**
 * Test set fade.
 */
@Test
public void testSetFade() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.setFade(128, 128);
    sprite.setFade(128, 128);
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 4 with Sprite

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

the class SpriteTest method testStretchInvalidWidth.

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

Example 5 with Sprite

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

the class SpriteTest method testFilterBilinear.

/**
 * Test filter bilinear.
 */
@Test
public void testFilterBilinear() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.filter(new FilterBilinear());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) FilterBilinear(com.b3dgs.lionengine.core.filter.FilterBilinear) Test(org.junit.Test)

Aggregations

Sprite (com.b3dgs.lionengine.graphic.Sprite)22 Test (org.junit.Test)22 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1