use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class CollidableModelTest method testDifferentSizes.
/**
* Test collidable class with different sizes.
*/
@Test
void testDifferentSizes() {
featurable1.addFeature(new MirrorableModel(services, setup));
featurable2.addFeature(new MirrorableModel(services, setup));
final AtomicBoolean auto = new AtomicBoolean();
collidable1.checkListener((CollidableListener) (collidable, with, by) -> auto.set(true));
final Collision collision1 = new Collision("test1", 1, 1, 1, 1, true);
final Collision collision2 = new Collision("test2", 0, 0, 3, 3, false);
collidable1.notifyCollided(collidable2, collision1, collision2);
assertTrue(auto.get());
collidable1.addCollision(collision1);
collidable2.addCollision(collision2);
transformable1.moveLocation(1.0, 1, 1);
transformable2.moveLocation(1.0, 0, 0);
assertEquals(Arrays.asList(new CollisionCouple(collision2, collision1)), collidable2.collide(collidable1));
transformable1.teleport(0.5, 3.5);
assertEquals(Arrays.asList(new CollisionCouple(collision2, collision1)), collidable2.collide(collidable1));
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class ComponentCollisionTest method prepare.
/**
* Prepare test.
*/
@BeforeEach
public void prepare() {
services.add(new Camera());
featurable1 = new ObjectSelf(services, setup);
transformable1 = featurable1.addFeatureAndGet(new TransformableModel(services, setup));
collidable1 = featurable1.addFeatureAndGet(new CollidableModel(services, setup));
collidable1.setGroup(Integer.valueOf(1));
collidable1.addAccept(Integer.valueOf(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(Integer.valueOf(1));
collidable2.setGroup(Integer.valueOf(0));
featurable1.addFeature(new MirrorableModel(services, setup));
featurable2.addFeature(new MirrorableModel(services, setup));
final Collision collision2 = new Collision("test2", 0, 0, 3, 3, true);
collidable2.addCollision(collision2);
handler.addComponent(component);
handler.add(featurable1);
handler.add(featurable2);
handler.add(nonCollidable);
final CollidableListener listener = (collidable, with, by) -> collide.set(collidable);
collidable2.addListener(listener);
}
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(services, setup);
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 AttackerModelTest method testNoConfig.
/**
* Test without config.
*/
@Test
void testNoConfig() {
final Media media = UtilTransformable.createMedia(AttackerModelTest.class);
final Xml xml = new Xml(media);
xml.save(media);
final AttackerModel attacker = new AttackerModel(services, new Setup(media));
assertTrue(attacker.getAttackDamages() == 0);
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class LauncherModelTest method testLauncherException.
/**
* Test the launcher failure.
*/
@Test
void testLauncherException() {
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 {
assertThrowsTimeout(1000L, () -> {
while (!launcher.fire()) {
launcher.update(1.0);
continue;
}
}, "Feature not found: " + Launchable.class.getName());
} finally {
final Handler handler = services.get(Handler.class);
handler.removeAll();
handler.update(1.0);
assertEquals(0, handler.size());
assertTrue(launchableMedia.getFile().delete());
}
}
Aggregations