Search in sources :

Example 16 with MapTile

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

the class MapCircuitExtractorTest method testCircuitMiddle.

/**
 * Check the middle circuit.
 */
@Test
void testCircuitMiddle() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_GROUND);
    UtilMap.fill(map, TILE_ROAD, TILE_ROAD, 3);
    assertEquals(new Circuit(CircuitType.MIDDLE, ROAD, ROAD), get(map, 3, 3));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 17 with MapTile

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

the class MapCircuitExtractorTest method testT3JTop.

/**
 * Check the three way junction top circuits.
 */
@Test
void testT3JTop() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_GROUND);
    map.setTile(2, 3, TILE_ROAD);
    map.setTile(3, 3, TILE_ROAD);
    map.setTile(4, 3, TILE_ROAD);
    map.setTile(3, 2, TILE_ROAD);
    assertEquals(new Circuit(CircuitType.T3J_TOP, ROAD, GROUND), get(map, 3, 3));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 18 with MapTile

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

the class MapCircuitExtractorTest method testVerticals.

/**
 * Check the vertical circuits.
 */
@Test
void testVerticals() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_GROUND);
    map.setTile(3, 2, TILE_ROAD);
    map.setTile(3, 3, TILE_ROAD);
    map.setTile(3, 4, TILE_ROAD);
    assertEquals(new Circuit(CircuitType.TOP, ROAD, GROUND), get(map, 3, 4));
    assertEquals(new Circuit(CircuitType.VERTICAL, ROAD, GROUND), get(map, 3, 3));
    assertEquals(new Circuit(CircuitType.BOTTOM, ROAD, GROUND), get(map, 3, 2));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 19 with MapTile

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

the class MapCircuitExtractorTest method testNullNeighbor.

/**
 * Check the circuit with <code>null</code> neighbors.
 */
@Test
void testNullNeighbor() {
    final MapTile map = UtilMap.createMap(7);
    map.setTile(4, 2, TILE_ROAD);
    map.setTile(3, 3, TILE_ROAD);
    assertNull(get(map, 3, 3));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 20 with MapTile

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

the class UtilMapCircuit method createCircuits.

/**
 * Create map with circuits.
 *
 * @param configTransition The transition configuration.
 * @return The created configuration.
 */
public static Media createCircuits(Media configTransition) {
    final MapTile map1 = UtilMap.createMap(6);
    map1.getFeature(MapTileTransition.class).loadTransitions(configTransition);
    UtilMap.fill(map1, TILE_GROUND);
    map1.setTile(1, 2, TILE_ROAD);
    map1.setTile(2, 3, TILE_ROAD);
    map1.setTile(2, 1, TILE_ROAD);
    map1.setTile(2, 2, TILE_ROAD);
    map1.setTile(3, 2, TILE_ROAD);
    map1.setTile(5, 5, TILE_ROAD);
    final MapTile map2 = UtilMap.createMap(5);
    map2.getFeature(MapTileTransition.class).loadTransitions(configTransition);
    UtilMap.fill(map2, TILE_GROUND);
    map2.setTile(1, 1, TILE_ROAD);
    map2.setTile(1, 2, TILE_ROAD);
    map2.setTile(1, 3, TILE_ROAD);
    map2.setTile(2, 1, TILE_ROAD);
    map2.setTile(2, 2, TILE_ROAD);
    map2.setTile(2, 3, TILE_ROAD);
    map2.setTile(3, 1, TILE_ROAD);
    map2.setTile(3, 2, TILE_ROAD);
    map2.setTile(3, 3, TILE_ROAD);
    final MapTile map3 = UtilMap.createMap(10);
    map3.getFeature(MapTileTransition.class).loadTransitions(configTransition);
    UtilMap.fill(map3, TILE_GROUND);
    map3.setTile(1, 2, TILE_ROAD);
    map3.setTile(2, 2, TILE_ROAD);
    map3.setTile(3, 2, TILE_ROAD);
    map3.setTile(2, 1, TILE_ROAD);
    map3.setTile(1, 5, TILE_ROAD);
    map3.setTile(2, 5, TILE_ROAD);
    map3.setTile(3, 5, TILE_ROAD);
    map3.setTile(2, 6, TILE_ROAD);
    map3.setTile(5, 6, TILE_ROAD);
    map3.setTile(5, 7, TILE_ROAD);
    map3.setTile(5, 8, TILE_ROAD);
    map3.setTile(6, 5, TILE_ROAD);
    map3.setTile(5, 6, TILE_ROAD);
    map3.setTile(5, 7, TILE_ROAD);
    map3.setTile(5, 8, TILE_ROAD);
    map3.setTile(6, 9, TILE_ROAD);
    final Media config = Medias.create("circuits.xml");
    CircuitsConfig.exports(config, new CircuitsExtractorImpl().getCircuits(Arrays.asList(map1, map2, map3)));
    return config;
}
Also used : MapTileTransition(com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition) Media(com.b3dgs.lionengine.Media) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile)

Aggregations

MapTile (com.b3dgs.lionengine.game.feature.tile.map.MapTile)58 Test (org.junit.jupiter.api.Test)34 Media (com.b3dgs.lionengine.Media)15 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)11 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)10 Collection (java.util.Collection)9 MapTileGroup (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroup)8 MapTileGroupModel (com.b3dgs.lionengine.game.feature.tile.map.MapTileGroupModel)7 MapTileTransition (com.b3dgs.lionengine.game.feature.tile.map.transition.MapTileTransition)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)4 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)3 Setup (com.b3dgs.lionengine.game.feature.Setup)3 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)3 Featurable (com.b3dgs.lionengine.game.feature.Featurable)2 Transformable (com.b3dgs.lionengine.game.feature.Transformable)2 UtilTransformable (com.b3dgs.lionengine.game.feature.UtilTransformable)2 FileReading (com.b3dgs.lionengine.io.FileReading)2 FileWriting (com.b3dgs.lionengine.io.FileWriting)2 HashSet (java.util.HashSet)2