use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.
the class ComponentCollision method notifyHandlableAdded.
/*
* HandlerListener
*/
@Override
public void notifyHandlableAdded(Featurable featurable) {
if (featurable.hasFeature(Collidable.class)) {
final Transformable transformable = featurable.getFeature(Transformable.class);
transformable.addListener(this);
}
}
use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.
the class MapTileFog method reset.
/**
* Reset the revealed tiles to fogged.
*
* @param fovable The fovable reference.
*/
void reset(Fovable fovable) {
final Transformable transformable = fovable.getFeature(Transformable.class);
final int tx = (int) Math.floor(transformable.getOldX() / map.getTileWidth());
final int ty = (int) Math.floor(transformable.getOldY() / map.getTileHeight());
final int tw = map.getInTileHeight(transformable) / 2;
final int th = map.getInTileHeight(transformable) / 2;
final int ray = fovable.getInTileFov() - 1;
final int sx = UtilMath.clamp(tx - ray - tw, 0, map.getInTileWidth() - 1);
final int ex = UtilMath.clamp(tx + ray + tw, 0, map.getInTileWidth() - 1);
final int sy = UtilMath.clamp(ty - ray - th, 0, map.getInTileHeight() - 1);
final int ey = UtilMath.clamp(ty + ray + th, 0, map.getInTileHeight() - 1);
for (int x = sx; x < ex + 1; x++) {
for (int y = sy; y < ey + 1; y++) {
if (map.getTile(x, y).getNumber() != FOG) {
map.setTile(x, y, FOG);
transition.resolve(map.getTile(x, y));
}
}
}
}
use of com.b3dgs.lionengine.game.feature.Transformable 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());
}
use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.
the class MapTileCollisionModelComplexTest method createObject.
/**
* Create object test.
*
* @return The object test.
*/
private Transformable createObject() {
final Setup setup = new Setup(config);
CollisionCategoryConfig.exports(setup.getRoot(), category);
final FeaturableModel object = new FeaturableModel(services, setup);
final Transformable transformable = object.addFeatureAndGet(new TransformableModel(services, setup));
transformable.setSize(1, 1);
final TileCollidable collidable = object.addFeatureAndGet(new TileCollidableModel(services, setup));
collidable.setEnabled(true);
return transformable;
}
use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.
the class MapTileCollisionModelTest method createObject.
/**
* Create object test.
*
* @return The object test.
*/
private Transformable createObject() {
final Setup setup = new Setup(config);
CollisionCategoryConfig.exports(setup.getRoot(), categoryY);
CollisionCategoryConfig.exports(setup.getRoot(), categoryX);
final FeaturableModel object = new FeaturableModel(services, setup);
final Transformable transformable = object.addFeatureAndGet(new TransformableModel(services, setup));
transformable.setSize(1, 1);
final TileCollidable collidable = object.addFeatureAndGet(new TileCollidableModel(services, setup));
collidable.setEnabled(true);
return transformable;
}
Aggregations