use of com.b3dgs.lionengine.graphic.SpriteParallaxed in project lionengine by b3dgs.
the class SpriteParallaxedTest method testParallax.
/**
* Test parallax sprite.
*/
@SuppressWarnings("unlikely-arg-type")
@Test
public void testParallax() {
final ImageHeader info = ImageInfo.get(media);
final SpriteParallaxed spriteA = Drawable.loadSpriteParallaxed(media, LINES, 60, 100);
spriteA.load(false);
Assert.assertTrue(spriteA.equals(spriteA));
Assert.assertEquals(info.getHeight() / LINES, spriteA.getHeight());
Assert.assertEquals(38, spriteA.getWidth());
Assert.assertEquals(41, spriteA.getLineWidth(2));
// Test render
spriteA.render(g, 0, 0, 0);
// Resize
final SpriteParallaxed spriteB = Drawable.loadSpriteParallaxed(media, LINES, 60, 100);
spriteB.stretch(200, 100);
spriteB.load(true);
Assert.assertFalse(spriteB.equals(spriteA));
Assert.assertTrue(spriteA.hashCode() != spriteB.hashCode());
Assert.assertFalse(spriteA.equals(media));
final SpriteParallaxed spriteC = Drawable.loadSpriteParallaxed(media, LINES, 60, 100);
spriteC.stretch(100, 200);
spriteC.load(true);
Assert.assertFalse(spriteC.equals(spriteA));
Assert.assertTrue(spriteA.hashCode() != spriteC.hashCode());
Assert.assertFalse(spriteA.equals(media));
}
use of com.b3dgs.lionengine.graphic.SpriteParallaxed in project lionengine by b3dgs.
the class SpriteParallaxedTest method testParallaxFailure.
/**
* Test parallax sprite failure.
*/
@Test
public void testParallaxFailure() {
try {
final SpriteParallaxed spriteC = Drawable.loadSpriteParallaxed(media, 0, 60, 100);
Assert.assertNotNull(spriteC);
Assert.fail();
} catch (final LionEngineException exception) {
// Success
Assert.assertNotNull(exception);
}
try {
final SpriteParallaxed spriteC = Drawable.loadSpriteParallaxed(media, LINES, 60, 0);
Assert.assertNotNull(spriteC);
Assert.fail();
} catch (final LionEngineException exception) {
// Success
Assert.assertNotNull(exception);
}
try {
final SpriteParallaxed spriteC = Drawable.loadSpriteParallaxed(media, LINES, 0, 60);
Assert.assertNotNull(spriteC);
Assert.fail();
} catch (final LionEngineException exception) {
// Success
Assert.assertNotNull(exception);
}
}
Aggregations