use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class AnimationConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
public void testExportsImports() {
final Xml root = new Xml("test");
final Animation animation1 = new Animation("anim1", 1, 2, 3.0, false, true);
final Animation animation2 = new Animation("anim2", 4, 5, 6.0, true, false);
AnimationConfig.exports(root, animation1);
AnimationConfig.exports(root, animation2);
final Media media = Medias.create("animations.xml");
root.save(media);
final AnimationConfig imported = AnimationConfig.imports(new Setup(media));
Assert.assertEquals(animation1, imported.getAnimation("anim1"));
Assert.assertEquals(animation2, imported.getAnimation("anim2"));
Assert.assertTrue(imported.getAnimations().containsAll(Arrays.asList(animation1, animation2)));
Assert.assertFalse(imported.hasAnimation("anim"));
Assert.assertTrue(imported.hasAnimation("anim1"));
Assert.assertTrue(imported.hasAnimation("anim2"));
Assert.assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class UtilActionnable method createActionable.
/**
* Create the actionable.
*
* @param media The media.
* @param services The services.
* @return The prepared actionable.
*/
public static ActionableModel createActionable(Media media, Services services) {
final Setup setup = new Setup(media);
final Featurable featurable = new FeaturableModel();
featurable.addFeature(new IdentifiableModel());
final ActionableModel actionable = new ActionableModel(services, setup);
actionable.prepare(featurable);
return actionable;
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class CollidableConfigTest method testExport.
/**
* Test export.
*/
@Test
public void testExport() {
final Media media = Medias.create("object.xml");
final Xml root = new Xml("test");
root.save(media);
final Services services = new Services();
services.add(new ViewerMock());
final Collidable collidable = new CollidableModel(services, new Setup(media));
collidable.setGroup(1);
CollidableConfig.exports(root, collidable);
root.save(media);
Assert.assertEquals(Integer.valueOf(1), CollidableConfig.imports(new Configurer(media)));
Assert.assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class ComponentCollisionTest method prepare.
/**
* Prepare test.
*/
@Before
public void prepare() {
services.add(new Camera());
featurable1 = new ObjectSelf();
transformable1 = featurable1.addFeatureAndGet(new TransformableModel(setup));
collidable1 = featurable1.addFeatureAndGet(new CollidableModel(services, setup));
collidable1.setGroup(1);
collidable1.addAccept(0);
final Collision collision1 = new Collision("test1", 0, 0, 3, 3, false);
collidable1.addCollision(collision1);
featurable2 = CollidableModelTest.createFeaturable(config, services);
transformable2 = featurable2.getFeature(Transformable.class);
collidable2 = featurable2.getFeature(Collidable.class);
collidable2.addAccept(1);
collidable2.setGroup(0);
final Collision collision2 = new Collision("test2", 0, 0, 3, 3, true);
collidable2.addCollision(collision2);
featurable3 = new ObjectSelf();
transformable3 = featurable3.addFeatureAndGet(new TransformableModel(setup));
collidable3 = featurable3.addFeatureAndGet(new CollidableModel(services, setup));
collidable3.setGroup(0);
final ComponentCollision component = new ComponentCollision();
handler.addComponent(component);
handler.add(featurable1);
handler.add(featurable2);
handler.add(featurable3);
handler.add(nonCollidable);
final CollidableListener listener = collidable -> collide.set(collidable);
collidable2.addListener(listener);
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class LauncherModelTest method testLauncherException.
/**
* Test the launcher failure.
*
* @throws InterruptedException If error.
*/
@Test(expected = LionEngineException.class)
public void testLauncherException() throws InterruptedException {
final Media launchableMedia = UtilSetup.createMedia(LaunchableObjectException.class);
final Media launcherMedia = UtilLaunchable.createLauncherMedia(launchableMedia);
final Setup setup = new Setup(launcherMedia);
final Launcher launcher = UtilLaunchable.createLauncher(services, setup, featurable);
try {
while (!launcher.fire()) {
continue;
}
Assert.fail();
} finally {
final Handler handler = services.get(Handler.class);
handler.removeAll();
handler.update(1.0);
Assert.assertEquals(0, handler.size());
Assert.assertTrue(launchableMedia.getFile().delete());
}
}
Aggregations