Search in sources :

Example 26 with MapTile

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

the class MapTransitionExtractorTest method testNullNeighbor.

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

Example 27 with MapTile

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

the class MapTransitionExtractorTest method testTransitionCenter.

/**
 * Check the center transition.
 */
@Test
void testTransitionCenter() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_WATER);
    UtilMap.fill(map, TILE_GROUND, TILE_TRANSITION, 3);
    final Transition transition = new Transition(TransitionType.CENTER, WATER, WATER);
    for (int tx = 0; tx < map.getInTileWidth(); tx++) {
        assertEquals(transition, get(map, tx, 0));
        assertEquals(transition, get(map, tx, map.getInTileHeight() - 1));
    }
    for (int ty = 0; ty < map.getInTileHeight(); ty++) {
        assertEquals(transition, get(map, 0, ty));
        assertEquals(transition, get(map, map.getInTileWidth() - 1, ty));
    }
    assertNull(get(map, map.getInTileWidth() / 2, map.getInTileHeight() / 2));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 28 with MapTile

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

the class MapTransitionExtractorTest method testCorners.

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

Example 29 with MapTile

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

the class MapTransitionExtractorTest method testThreeGroups.

/**
 * Check the three groups transition.
 * <p>
 * Problem here consists in having more than two groups to solve transition, which requires two different groups.
 * </p>
 */
@Test
void testThreeGroups() {
    final MapTile map = UtilMap.createMap(7);
    UtilMap.fill(map, TILE_WATER);
    map.setTile(1, 1, TILE_GROUND);
    map.setTile(3, 3, TILE_TREE);
    assertNull(get(map, 2, 2));
}
Also used : MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Test(org.junit.jupiter.api.Test)

Example 30 with MapTile

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

the class TransitionsExtractorImpl method getTransitions.

@Override
public Map<Transition, Collection<Integer>> getTransitions(Collection<MapTile> maps) {
    final Map<Transition, Collection<Integer>> transitions = new HashMap<>();
    for (final MapTile map : maps) {
        final Map<Transition, Collection<Integer>> currents = getTransitions(map);
        for (final Entry<Transition, Collection<Integer>> entry : currents.entrySet()) {
            final Transition transition = entry.getKey();
            final Collection<Integer> tiles = entry.getValue();
            if (transitions.containsKey(transition)) {
                transitions.get(transition).addAll(tiles);
            } else {
                transitions.put(transition, tiles);
            }
        }
    }
    return transitions;
}
Also used : HashMap(java.util.HashMap) Collection(java.util.Collection) 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