Search in sources :

Example 1 with LayerableModel

use of com.b3dgs.lionengine.game.feature.LayerableModel 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 2 with LayerableModel

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

the class SelectorRefresherTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    services.add(new ContextMock());
    services.add(new Camera());
    services.add(new ViewerMock());
    cursor = services.create(Cursor.class);
    cursor.setSync(mouse);
    final Featurable featurable = new FeaturableModel(services, setup);
    featurable.addFeature(new LayerableModel(services, setup));
    featurable.addFeature(new TransformableModel(services, setup));
    featurable.addFeature(new CollidableModel(services, setup));
    refresher = new SelectorRefresher(services, model);
    refresher.addListener(listener);
    refresher.prepare(featurable);
}
Also used : CollidableModel(com.b3dgs.lionengine.game.feature.collidable.CollidableModel) ViewerMock(com.b3dgs.lionengine.ViewerMock) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Camera(com.b3dgs.lionengine.game.feature.Camera) ContextMock(com.b3dgs.lionengine.ContextMock) Cursor(com.b3dgs.lionengine.game.Cursor) Featurable(com.b3dgs.lionengine.game.feature.Featurable) SelectorRefresher(com.b3dgs.lionengine.game.feature.collidable.selector.SelectorRefresher) LayerableModel(com.b3dgs.lionengine.game.feature.LayerableModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 LayerableModel (com.b3dgs.lionengine.game.feature.LayerableModel)2 ContextMock (com.b3dgs.lionengine.ContextMock)1 Media (com.b3dgs.lionengine.Media)1 ViewerMock (com.b3dgs.lionengine.ViewerMock)1 Cursor (com.b3dgs.lionengine.game.Cursor)1 Camera (com.b3dgs.lionengine.game.feature.Camera)1 Factory (com.b3dgs.lionengine.game.feature.Factory)1 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)1 Transformable (com.b3dgs.lionengine.game.feature.Transformable)1 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)1 CollidableModel (com.b3dgs.lionengine.game.feature.collidable.CollidableModel)1 Hud (com.b3dgs.lionengine.game.feature.collidable.selector.Hud)1 Selector (com.b3dgs.lionengine.game.feature.collidable.selector.Selector)1 SelectorRefresher (com.b3dgs.lionengine.game.feature.collidable.selector.SelectorRefresher)1 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)1 MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)1 MapTilePath (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePath)1 MapTilePathModel (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePathModel)1 Pathfindable (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.Pathfindable)1