use of com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel in project lionengine by b3dgs.
the class Scene method load.
@Override
public void load() {
final MapTileGame map = services.create(MapTileGame.class);
map.create(Medias.create("level.png"));
final Camera camera = services.create(Camera.class);
camera.setIntervals(16, 0);
camera.setView(0, 0, getWidth(), getHeight(), getHeight());
camera.setLimits(map);
handler.add(camera);
final MapTileGroup mapGroup = map.addFeatureAndGet(new MapTileGroupModel());
final MapTileCollision mapCollision = map.addFeatureAndGet(new MapTileCollisionModel());
mapCollisionRenderer = map.addFeatureAndGet(new MapTileCollisionRendererModel());
handler.add(map);
mapGroup.loadGroups(Medias.create("groups.xml"));
mapCollision.loadCollisions(Medias.create("formulas.xml"), Medias.create("collisions.xml"));
mapCollisionRenderer.createCollisionDraw();
final MapTileViewer mapViewer = map.addFeatureAndGet(new MapTileViewerModel(services));
mapViewer.addRenderer(mapCollisionRenderer);
mapViewer.prepare(map);
final Factory factory = services.create(Factory.class);
final Mario mario = factory.create(Mario.MEDIA);
mario.getFeature(Transformable.class).teleport(400, 31);
handler.add(mario);
final CameraTracker tracker = new CameraTracker(services);
tracker.track(mario);
handler.add(tracker);
clear.start();
tick.start();
}
use of com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel in project lionengine by b3dgs.
the class Scene method load.
@Override
public void load() {
map.create(Medias.create("level.png"));
camera.setView(0, 0, getWidth(), getHeight(), getHeight());
camera.setLocation(160, 96);
map.create(Medias.create("level.png"));
map.addFeature(new MapTileViewerModel(services));
map.addFeatureAndGet(new MapTileGroupModel()).loadGroups(Medias.create("groups.xml"));
map.addFeatureAndGet(new MapTilePathModel()).loadPathfinding(Medias.create("pathfinding.xml"));
camera.setLimits(map);
handler.add(map);
final Featurable peon1 = factory.create(Peon.MEDIA);
peon1.getFeature(Pathfindable.class).setLocation(20, 16);
peon1.getFeature(Pathfindable.class).setDestination(23, 12);
peon1.getFeature(Pathfindable.class).pointTo(1, 2);
handler.add(peon1);
peon2 = factory.create(Peon.MEDIA);
peon2.getFeature(Pathfindable.class).setLocation(22, 8);
handler.add(peon2);
final Featurable peon3 = factory.create(Peon.MEDIA);
peon3.getFeature(Pathfindable.class).setLocation(25, 10);
assertTrue(peon3.getFeature(Pathfindable.class).isPathAvailable(23, 12));
peon3.getFeature(Pathfindable.class).setDestination(23, 12);
handler.add(peon3);
peon2.getFeature(Pathfindable.class).setIgnoreId(peon3.getFeature(Identifiable.class).getId(), true);
peon2.getFeature(Pathfindable.class).pointTo(map.getTile(25, 25));
assertEquals(Orientation.NORTH_EAST, peon2.getFeature(Pathfindable.class).getOrientation());
peon2.getFeature(Pathfindable.class).setOrientation(Orientation.NORTH_WEST);
assertEquals(Orientation.NORTH_WEST, peon2.getFeature(Pathfindable.class).getOrientation());
peon2.getFeature(Pathfindable.class).addListener(listener);
tick.start();
}
use of com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel 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();
}
use of com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel in project lionengine by b3dgs.
the class MapTileRasteredModelTest method prepare.
/**
* Prepare test.
*/
@BeforeEach
public void prepare() {
services.add(new Camera());
viewer = services.add(new ViewerMock());
viewer.set(-20, -20);
map = services.add(new MapTileGame());
mapViewer = new MapTileViewerModel(services);
mapViewer.prepare(map);
mapRastered = new MapTileRasteredModel();
mapRastered.prepare(map);
}
Aggregations