Search in sources :

Example 16 with Transformable

use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.

the class TileCollidableModelTest method testFromRight.

/**
 * Test the collidable from right.
 */
@Test
void testFromRight() {
    final Transformable transformable = createObject(new FeaturableModel(services, setup));
    final AtomicReference<Tile> collided = new AtomicReference<>();
    final TileCollidableListener listener = createListener(collided);
    collidable.addListener(listener);
    transformable.teleport(3.0, 0.0);
    transformable.moveLocation(1.0, -2.0, 0.0);
    collidable.update(1.0);
    assertEquals(map.getTile(2, 0), collided.get());
}
Also used : Transformable(com.b3dgs.lionengine.game.feature.Transformable) Tile(com.b3dgs.lionengine.game.feature.tile.Tile) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.jupiter.api.Test)

Example 17 with Transformable

use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.

the class MapTilePathModelTest method createObject.

/**
 * Create object test.
 *
 * @return The object test.
 */
private Pathfindable createObject() {
    final FeaturableModel object = new FeaturableModel(services, setup);
    final Transformable transformable = object.addFeatureAndGet(new TransformableModel(services, setup));
    transformable.setSize(1, 1);
    return object.addFeatureAndGet(new PathfindableModel(services, setup));
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel)

Example 18 with Transformable

use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.

the class Scene method load.

@Override
public void load() {
    map.create(Medias.create("forest.png"));
    final MapTileGroup mapGroup = map.addFeatureAndGet(new MapTileGroupModel());
    final MapTilePath mapPath = map.addFeatureAndGet(new MapTilePathModel());
    camera.setView(VIEW_X, VIEW_Y, getWidth() - VIEW_X, getHeight() - VIEW_Y, getHeight());
    camera.setLimits(map);
    camera.setLocation(160, 96);
    map.addFeature(new MapTileViewerModel(services));
    handler.add(map);
    mapGroup.loadGroups(Medias.create("groups.xml"));
    mapPath.loadPathfinding(Medias.create("pathfinding.xml"));
    cursor.addImage(0, Medias.create("cursor.png"));
    cursor.addImage(1, Medias.create("cursor_order.png"));
    cursor.load();
    cursor.setGrid(map.getTileWidth(), map.getTileHeight());
    cursor.setSync(mouse);
    cursor.setViewer(camera);
    final Factory factory = services.create(Factory.class);
    final Media media = Medias.create("Hud.xml");
    final Hud hud = factory.create(media);
    handler.add(hud);
    final Selector selector = services.get(Selector.class);
    selector.addFeatureAndGet(new LayerableModel(4));
    selector.setClickableArea(camera);
    selector.setSelectionColor(ColorRgba.GREEN);
    selector.setClickSelection(MouseAwt.LEFT);
    final Featurable peon = factory.create(Medias.create("Peon.xml"));
    peon.getFeature(Pathfindable.class).setLocation(20, 10);
    handler.add(peon);
    transformable = peon.getFeature(Transformable.class);
    tick.start();
}
Also used : Media(com.b3dgs.lionengine.Media) Factory(com.b3dgs.lionengine.game.feature.Factory) Transformable(com.b3dgs.lionengine.game.feature.Transformable) LayerableModel(com.b3dgs.lionengine.game.feature.LayerableModel) MapTilePath(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePath) MapTilePathModel(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePathModel) Pathfindable(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.Pathfindable) MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) Hud(com.b3dgs.lionengine.game.feature.collidable.selector.Hud) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTileViewerModel(com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Selector(com.b3dgs.lionengine.game.feature.collidable.selector.Selector)

Example 19 with Transformable

use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.

the class CollidableModelTest method createFeaturable.

/**
 * Create a featurable test.
 *
 * @param config The configuration reference.
 * @param services The services reference.
 * @return The featurable test.
 */
public static FeaturableModel createFeaturable(Media config, Services services) {
    final Setup setup = new Setup(config);
    final FeaturableModel featurable = new FeaturableModel(services, setup);
    final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
    transformable.setLocation(1.0, 2.0);
    transformable.setSize(2, 2);
    featurable.addFeature(new CollidableModel(services, setup));
    return featurable;
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup)

Example 20 with Transformable

use of com.b3dgs.lionengine.game.feature.Transformable in project lionengine by b3dgs.

the class CollidableFramedModelTest method createFeaturable.

/**
 * Create a featurable test.
 *
 * @param config The configuration reference.
 * @param services The services reference.
 * @return The featurable test.
 */
public static FeaturableModel createFeaturable(Media config, Services services) {
    final Setup setup = new Setup(config);
    final FeaturableModel featurable = new FeaturableModel(services, setup);
    final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
    transformable.setLocation(1.0, 2.0);
    featurable.addFeature(new AnimatableModel(services, setup));
    featurable.addFeatureAndGet(new CollidableModel(services, setup));
    featurable.addFeature(new CollidableFramedModel(services, setup));
    return featurable;
}
Also used : CollidableModel(com.b3dgs.lionengine.game.feature.collidable.CollidableModel) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup)

Aggregations

Transformable (com.b3dgs.lionengine.game.feature.Transformable)30 Test (org.junit.jupiter.api.Test)17 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)16 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)15 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 Setup (com.b3dgs.lionengine.game.feature.Setup)8 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)7 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)6 UtilTransformable (com.b3dgs.lionengine.game.feature.UtilTransformable)6 Featurable (com.b3dgs.lionengine.game.feature.Featurable)4 Media (com.b3dgs.lionengine.Media)3 Medias (com.b3dgs.lionengine.Medias)3 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)3 Handler (com.b3dgs.lionengine.game.feature.Handler)3 Services (com.b3dgs.lionengine.game.feature.Services)3 Animation (com.b3dgs.lionengine.Animation)2 Range (com.b3dgs.lionengine.Range)2 UtilAssert.assertEquals (com.b3dgs.lionengine.UtilAssert.assertEquals)2 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)2 Force (com.b3dgs.lionengine.game.Force)2