Search in sources :

Example 26 with SpriteAnimated

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

the class SpriteAnimatedTest method testRotate.

/**
 * Test rotate sprite.
 */
@Test
public void testRotate() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    for (int angle = -720; angle < 720; angle++) {
        sprite.rotate(angle);
        Assert.assertTrue(angle + Constant.SPACE + sprite.getWidth(), sprite.getWidth() >= 64);
        Assert.assertTrue(angle + Constant.SPACE + sprite.getHeight(), sprite.getHeight() >= 32);
    }
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 27 with SpriteAnimated

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

the class SpriteAnimatedTest method testLoadMediaAlready.

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

Example 28 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetFrameOffset.

/**
 * Test set frame offset.
 */
@Test
public void testSetFrameOffset() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setFrameOffsets(1, -1);
    Assert.assertEquals(1, sprite.getFrameOffsetX());
    Assert.assertEquals(-1, sprite.getFrameOffsetY());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 29 with SpriteAnimated

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

the class SpriteAnimatedTest method testUpdateLoopNoReverse.

/**
 * Test update with loop but no reverse.
 */
@Test
public void testUpdateLoopNoReverse() {
    final Animation animation = new Animation(Animation.DEFAULT_NAME, 1, 3, 1.0, false, true);
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.play(animation);
    Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
    Assert.assertEquals(1, sprite.getFrame());
    Assert.assertEquals(1, sprite.getFrameAnim());
    sprite.update(1.0);
    Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
    Assert.assertEquals(2, sprite.getFrame());
    Assert.assertEquals(2, sprite.getFrameAnim());
    sprite.update(1.0);
    Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
    Assert.assertEquals(3, sprite.getFrame());
    Assert.assertEquals(3, sprite.getFrameAnim());
    sprite.update(1.0);
    Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
    Assert.assertEquals(1, sprite.getFrame());
    Assert.assertEquals(1, sprite.getFrameAnim());
    sprite.update(1.0);
    Assert.assertEquals(AnimState.PLAYING, sprite.getAnimState());
    Assert.assertEquals(2, sprite.getFrame());
    Assert.assertEquals(2, sprite.getFrameAnim());
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Animation(com.b3dgs.lionengine.Animation) Test(org.junit.Test)

Example 30 with SpriteAnimated

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

the class SpriteAnimatedTest method testFilterNull.

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

Aggregations

SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)33 Test (org.junit.Test)33 Animation (com.b3dgs.lionengine.Animation)6 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 Media (com.b3dgs.lionengine.Media)1 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1