use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class MapTilePersisterModelTest method testConstructor.
/**
* Test the constructor with services with map.
*/
@Test
void testConstructor() {
final MapTile map = new MapTileGame();
final MapTilePersister mapPersister = new MapTilePersisterModel();
assertNotNull(mapPersister);
mapPersister.prepare(map);
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class MapTilePersisterModelTest method testSaveLoadWithConfig.
/**
* Test the save and load map from file with sheet config.
*
* @throws IOException If error.
*/
@Test
void testSaveLoadWithConfig() throws IOException {
final Media config = Medias.create("config.xml");
TileSheetsConfig.exports(config, 16, 32, new ArrayList<String>());
final MapTileGame map = new MapTileGame();
map.addFeature(new MapTilePersisterModel());
map.create(16, 32, 3, 3);
map.loadSheets(config);
final Media level = Medias.create("level");
UtilMapTilePersister.saveMap(map, level);
final MapTileGame mapLoaded = UtilMapTilePersister.loadMap(level);
mapLoaded.loadSheets(config);
assertEquals(config, mapLoaded.getMedia());
assertTrue(config.getFile().delete());
assertTrue(level.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class MapTilePersisterModelTest method testListener.
/**
* Test load listener.
*
* @throws IOException If error.
*/
@Test
void testListener() throws IOException {
final MapTileGame map = new MapTileGame();
final MapTilePersister mapPersister = map.addFeatureAndGet(new MapTilePersisterModel());
final Media level = Medias.create("level");
map.create(16, 32, 3, 3);
UtilMapTilePersister.saveMap(map, level);
final AtomicBoolean load = new AtomicBoolean();
final MapTilePersisterListener listener = new MapTilePersisterListener() {
@Override
public void notifyMapLoadStart() {
load.set(false);
}
@Override
public void notifyMapLoaded() {
load.set(true);
}
};
mapPersister.addListener(listener);
try (FileReading input = new FileReading(level)) {
mapPersister.load(input);
}
assertTrue(load.get());
load.set(false);
mapPersister.removeListener(listener);
try (FileReading input = new FileReading(level)) {
mapPersister.load(input);
}
assertFalse(load.get());
assertTrue(level.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame 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);
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class MapTileViewerModelTest 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);
}
Aggregations