use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class UtilLaunchable method createLaunchable.
/**
* Create launchable.
*
* @param services The services.
* @param setup The setup.
* @param featurable The featurable.
* @return The launchable.
*/
public static Launchable createLaunchable(Services services, Setup setup, Featurable featurable) {
featurable.addFeature(new TransformableModel(services, setup));
final Launchable launchable = new LaunchableModel(services, setup);
launchable.prepare(featurable);
launchable.setLocation(0.0, 0.0);
launchable.setVector(new Force(0.0, 1.0));
return launchable;
}
use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class TransformableModelTest method testMoveLocation.
/**
* Test the transformable moving.
*/
@Test
void testMoveLocation() {
assertLocalization(0.0, 0.0, 0.0, 0.0);
transformable.backup();
transformable.moveLocation(1.0, 1.0, 2.0);
assertLocalization(0.0, 0.0, 1.0, 2.0);
transformable.backup();
transformable.moveLocation(1.0, new Force(-2.0, -3.0), new Force(-1.0, -2.0));
assertLocalization(1.0, 2.0, -2.0, -3.0);
}
use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class LauncherModelTest method testLauncherInitial.
/**
* Test the launcher with initial speed.
*
* @throws InterruptedException If error.
*/
@Test
void testLauncherInitial() throws InterruptedException {
final AtomicBoolean fired = new AtomicBoolean();
final AtomicReference<Launchable> firedLaunchable = new AtomicReference<>();
launcher.addListener(UtilLaunchable.createListener(fired));
launcher.addListener(UtilLaunchable.createListener(firedLaunchable));
final Force force = new Force(1.0, 2.0);
assertTimeout(1000L, () -> {
while (!launcher.fire(force)) {
launcher.update(1.0);
continue;
}
});
assertTrue(fired.get());
assertNotNull(firedLaunchable.get());
final Transformable transformable = firedLaunchable.get().getFeature(Transformable.class);
assertEquals(2.0, transformable.getX());
assertEquals(4.0, transformable.getY());
final Handler handler = services.get(Handler.class);
handler.update(1.0);
assertEquals(1, handler.size());
handler.removeAll();
handler.update(1.0);
assertEquals(0, handler.size());
}
Aggregations