Search in sources :

Example 1 with SpriteAnimated

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

the class SceneRasterable method load.

@Override
public void load() {
    final SetupSurfaceRastered setup = new SetupSurfaceRastered(Medias.create("object.xml"), Medias.create("raster.xml"));
    final SpriteAnimated surface = Drawable.loadSpriteAnimated(setup.getSurface(), 4, 4);
    final Featurable featurable = new FeaturableModel();
    featurable.addFeature(new MirrorableModel());
    featurable.addFeature(new AnimatableModel(surface));
    final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel());
    final Rasterable rasterable = new RasterableModel(services, setup);
    rasterable.setOrigin(Origin.MIDDLE);
    featurable.addFeature(rasterable);
    featurable.addFeature(new RefreshableModel(extrp -> {
        transformable.setLocationY(UtilMath.sin(count * 3) * 240);
        surface.setLocation(camera, transformable);
        rasterable.update(extrp);
        surface.update(extrp);
    }));
    featurable.addFeature(new DisplayableModel(g -> rasterable.render(g)));
    transformable.setLocationX(120);
    handler.add(featurable);
    camera.setView(0, 0, getWidth(), getHeight(), getHeight());
    timing.start();
}
Also used : ComponentRefreshable(com.b3dgs.lionengine.game.feature.ComponentRefreshable) RefreshableModel(com.b3dgs.lionengine.game.feature.RefreshableModel) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) ComponentDisplayable(com.b3dgs.lionengine.game.feature.ComponentDisplayable) Engine(com.b3dgs.lionengine.core.Engine) Timing(com.b3dgs.lionengine.Timing) Resolution(com.b3dgs.lionengine.Resolution) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) Services(com.b3dgs.lionengine.game.feature.Services) RasterableModel(com.b3dgs.lionengine.game.feature.rasterable.RasterableModel) SetupSurfaceRastered(com.b3dgs.lionengine.game.feature.rasterable.SetupSurfaceRastered) Medias(com.b3dgs.lionengine.core.Medias) Drawable(com.b3dgs.lionengine.core.drawable.Drawable) Handler(com.b3dgs.lionengine.game.feature.Handler) MirrorableModel(com.b3dgs.lionengine.game.feature.MirrorableModel) Rasterable(com.b3dgs.lionengine.game.feature.rasterable.Rasterable) Graphic(com.b3dgs.lionengine.graphic.Graphic) DisplayableModel(com.b3dgs.lionengine.game.feature.DisplayableModel) SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Sequence(com.b3dgs.lionengine.core.sequence.Sequence) Transformable(com.b3dgs.lionengine.game.feature.Transformable) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Context(com.b3dgs.lionengine.Context) UtilMath(com.b3dgs.lionengine.util.UtilMath) Origin(com.b3dgs.lionengine.Origin) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Camera(com.b3dgs.lionengine.game.feature.Camera) RefreshableModel(com.b3dgs.lionengine.game.feature.RefreshableModel) DisplayableModel(com.b3dgs.lionengine.game.feature.DisplayableModel) MirrorableModel(com.b3dgs.lionengine.game.feature.MirrorableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Rasterable(com.b3dgs.lionengine.game.feature.rasterable.Rasterable) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) RasterableModel(com.b3dgs.lionengine.game.feature.rasterable.RasterableModel) SetupSurfaceRastered(com.b3dgs.lionengine.game.feature.rasterable.SetupSurfaceRastered) SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 2 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetAlpha.

/**
 * Test set alpha.
 */
@Test
public void testSetAlpha() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(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 : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 3 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetAlphaHigh.

/**
 * Test set alpha too high.
 */
@Test(expected = LionEngineException.class)
public void testSetAlphaHigh() {
    final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
    sprite.setAlpha(256);
}
Also used : SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 4 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetFade.

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

Example 5 with SpriteAnimated

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

the class SpriteAnimatedTest method testSetOriginNull.

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

Aggregations

SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)35 Test (org.junit.Test)34 Animation (com.b3dgs.lionengine.Animation)6 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 Media (com.b3dgs.lionengine.Media)2 Graphic (com.b3dgs.lionengine.graphic.Graphic)2 Context (com.b3dgs.lionengine.Context)1 Origin (com.b3dgs.lionengine.Origin)1 Resolution (com.b3dgs.lionengine.Resolution)1 Timing (com.b3dgs.lionengine.Timing)1 Engine (com.b3dgs.lionengine.core.Engine)1 Medias (com.b3dgs.lionengine.core.Medias)1 Drawable (com.b3dgs.lionengine.core.drawable.Drawable)1 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Sequence (com.b3dgs.lionengine.core.sequence.Sequence)1 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)1 Camera (com.b3dgs.lionengine.game.feature.Camera)1 ComponentDisplayable (com.b3dgs.lionengine.game.feature.ComponentDisplayable)1 ComponentRefreshable (com.b3dgs.lionengine.game.feature.ComponentRefreshable)1 DisplayableModel (com.b3dgs.lionengine.game.feature.DisplayableModel)1