Search in sources :

Example 51 with MapTile

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

the class MapTransitionExtractorTest method testDiagonalInverted.

/**
 * Check the diagonal inverted transitions.
 */
@Test
void testDiagonalInverted() {
    final MapTile map = UtilMap.createMap(9);
    UtilMap.fill(map, TILE_WATER);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 5, 3);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3, 5);
    assertEquals(new Transition(TransitionType.UP_LEFT_DOWN_RIGHT, WATER, GROUND), get(map, 4, 4));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 52 with MapTile

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

the class MapTransitionExtractorTest method testVerticals.

/**
 * Check the vertical transitions.
 */
@Test
void testVerticals() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_WATER);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
    assertEquals(new Transition(TransitionType.UP, WATER, GROUND), get(map, 3, 4));
    assertEquals(new Transition(TransitionType.DOWN, WATER, GROUND), get(map, 3, 2));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 53 with MapTile

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

the class TransitionsExtractorTest method testExtraction.

/**
 * Test the transitions extraction.
 */
@Test
void testExtraction() {
    final MapTile map = createMap(services, setup, 7);
    UtilMap.fill(map, TILE_WATER);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
    final MapTile map2 = createMap(services, setup, 7);
    UtilMap.fill(map2, TILE_GROUND);
    UtilMap.fill(map2, TILE_WATER, TILE_TRANSITION, 3);
    final MapTile map3 = createMap(services, setup, 3);
    final TransitionsExtractor extractor = new TransitionsExtractorImpl();
    final Map<Transition, Collection<Integer>> transitions = extractor.getTransitions(Arrays.asList(map, map2, map3));
    has(transitions, TransitionType.UP_LEFT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.UP_LEFT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.UP, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.UP, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.UP_RIGHT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.UP_RIGHT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.DOWN_LEFT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.DOWN_LEFT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.DOWN, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.DOWN, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.DOWN_RIGHT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.DOWN_RIGHT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.LEFT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.LEFT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.RIGHT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.RIGHT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_UP_LEFT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_UP_LEFT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_UP_RIGHT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_UP_RIGHT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_DOWN_LEFT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_DOWN_LEFT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_DOWN_RIGHT, WATER, GROUND, TILE_TRANSITION);
    has(transitions, TransitionType.CORNER_DOWN_RIGHT, GROUND, WATER, TILE_TRANSITION);
    has(transitions, TransitionType.CENTER, WATER, WATER, TILE_WATER);
    has(transitions, TransitionType.CENTER, GROUND, GROUND, TILE_GROUND);
}
Also used : Collection(java.util.Collection) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 54 with MapTile

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

the class MapCircuitExtractorTest method testBlock.

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

Example 55 with MapTile

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

the class MapCircuitExtractorTest method testHorizontals.

/**
 * Check the horizontal circuits.
 */
@Test
void testHorizontals() {
    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);
    assertEquals(new Circuit(CircuitType.LEFT, ROAD, GROUND), get(map, 2, 3));
    assertEquals(new Circuit(CircuitType.HORIZONTAL, ROAD, GROUND), get(map, 3, 3));
    assertEquals(new Circuit(CircuitType.RIGHT, ROAD, GROUND), get(map, 4, 3));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

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