Search in sources :

Example 1 with MapTileGroupModel

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel in project lionengine by b3dgs.

the class TransitionConfigTest method testExportsImports.

/**
 * Test exports and imports.
 *
 * @throws IOException If error.
 */
@Test
public void testExportsImports() throws IOException {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, UtilMap.TILE_WATER);
    UtilMap.fill(map, UtilMap.TILE_WATER, UtilMap.TILE_TRANSITION, 3);
    final MapTile map2 = UtilMap.createMap(7);
    UtilMap.fill(map, UtilMap.TILE_WATER);
    UtilMap.fill(map, UtilMap.TILE_GROUND, UtilMap.TILE_TRANSITION, 3);
    final MapTile map3 = new MapTileGame();
    map3.addFeature(new MapTileGroupModel());
    map3.create(1, 1, 3, 3);
    final TransitionsExtractor extractor = new TransitionsExtractorImpl();
    final Map<Transition, Collection<TileRef>> transitions = extractor.getTransitions(Arrays.asList(map, map2, map3));
    final Media media = Medias.create("transition.xml");
    TransitionsConfig.exports(media, transitions);
    Assert.assertEquals(transitions, TransitionsConfig.imports(media));
    Assert.assertTrue(media.getFile().delete());
}
Also used : MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Media(com.b3dgs.lionengine.Media) Collection(java.util.Collection) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.Test)

Example 2 with MapTileGroupModel

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel 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();
}
Also used : MapTileViewer(com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewer) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Factory(com.b3dgs.lionengine.game.feature.Factory) Transformable(com.b3dgs.lionengine.game.feature.Transformable) CameraTracker(com.b3dgs.lionengine.game.feature.CameraTracker) MapTileGroup(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup) MapTileCollision(com.b3dgs.lionengine.game.feature.tile.map.collision.MapTileCollision) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) Camera(com.b3dgs.lionengine.game.feature.Camera) MapTileCollisionRendererModel(com.b3dgs.lionengine.game.feature.tile.map.collision.MapTileCollisionRendererModel) MapTileViewerModel(com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel) MapTileCollisionModel(com.b3dgs.lionengine.game.feature.tile.map.collision.MapTileCollisionModel)

Example 3 with MapTileGroupModel

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel in project lionengine by b3dgs.

the class Scene method load.

@Override
public void load() {
    map.create(Medias.create("forest.png"));
    mapViewer.prepare(map);
    final Media media = Medias.create("transitions.xml");
    TransitionsConfig.exports(media, Arrays.asList(Medias.create("forest.png")), Medias.create("sheets.xml"), Medias.create("groups.xml"));
    map.addFeatureAndGet(new MapTileGroupModel()).loadGroups(Medias.create("groups.xml"));
    map.addFeatureAndGet(new MapTileTransitionModel()).loadTransitions(Medias.create("transitions.xml"));
    map.addFeatureAndGet(new MapTileCircuitModel()).loadCircuits(Medias.create("circuits.xml"));
    UtilFile.deleteFile(media.getFile());
    camera.setView(0, 0, 1024, 768, getHeight());
    camera.setLimits(map);
    parameters.add(new PrefMapSize(16, 16, 64, 48)).add(new PrefMapFill(0)).add(new PrefMapRegion(12, new TileArea(0, 0, 8, 48), 4, 60)).add(new PrefMapRegion(12, new TileArea(56, 0, 64, 48), 4, 60)).add(new PrefMapRegion(12, new TileArea(0, 0, 64, 8), 4, 60)).add(new PrefMapRegion(12, new TileArea(0, 40, 64, 48), 4, 60)).add(new PrefMapRegion(29, new TileArea(12, 12, 56, 42), 2, 250)).add(new PrefMapRegion(12, new TileArea(24, 24, 40, 40), 2, 80)).add(new PrefMapRegion(0, new TileArea(4, 4, 60, 40), 1, 100));
    tickGen.start();
    tick.start();
}
Also used : PrefMapSize(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.generator.PrefMapSize) TileArea(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.generator.TileArea) PrefMapRegion(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.generator.PrefMapRegion) Media(com.b3dgs.lionengine.Media) PrefMapFill(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.generator.PrefMapFill) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) MapTileTransitionModel(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel) MapTileCircuitModel(com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuitModel)

Example 4 with MapTileGroupModel

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel in project lionengine by b3dgs.

the class CollisionGroupConfigTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    final MapTileGame map = new MapTileGame();
    map.addFeature(new MapTileGroupModel());
    mapCollision = new MapTileCollisionModel();
    mapCollision.prepare(map);
}
Also used : MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with MapTileGroupModel

use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel in project lionengine by b3dgs.

the class MapTileCollisionModelTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    map.addFeature(new MapTileGroupModel());
    map.create(1, 1, 3, 3);
    UtilMap.setGroups(map);
    UtilMap.fill(map, UtilMap.TILE_GROUND);
    mapCollision = map.addFeatureAndGet(new MapTileCollisionModel());
    mapCollision.prepare(map);
    formulasConfig = UtilConfig.createFormulaConfig(formulaV, formulaH);
    groupsConfig = UtilConfig.createGroupsConfig(group);
    mapCollision.loadCollisions(formulasConfig, groupsConfig);
    transformable = createObject();
}
Also used : MapTileGroupModel(com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)19 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)11 Media (com.b3dgs.lionengine.Media)9 MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)7 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 MapTileTransition (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)4 MapTileTransitionModel (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransitionModel)4 Collection (java.util.Collection)4 Camera (com.b3dgs.lionengine.game.feature.Camera)3 MapTileCircuitModel (com.b3dgs.lionengine.game.feature.tile.map.transition.circuit.MapTileCircuitModel)3 MapTileViewerModel (com.b3dgs.lionengine.game.feature.tile.map.viewer.MapTileViewerModel)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 Factory (com.b3dgs.lionengine.game.feature.Factory)2 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 Transformable (com.b3dgs.lionengine.game.feature.Transformable)2 MapTilePathModel (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.MapTilePathModel)2 Pathfindable (com.b3dgs.lionengine.game.feature.tile.map.pathfinding.Pathfindable)2 HashSet (java.util.HashSet)2