use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class HandlerPersisterTest method testWithMapCollidable.
/**
* Test with map and collidable.
*
* @throws IOException If error.
*/
@Test
void testWithMapCollidable() throws IOException {
services.add(new Camera());
final MapTile map = services.add(new MapTileGame());
map.create(16, 16, 5, 5);
final Featurable featurable = factory.create(Medias.create("ObjectColl.xml"));
featurable.getFeature(Transformable.class).teleport(16, 32);
handler.add(featurable);
handler.update(1.0);
final HandlerPersister persister = new HandlerPersister(services);
final Media media = Medias.create("persister.data");
try (FileWriting writing = new FileWriting(media)) {
persister.save(writing);
}
final Services services2 = new Services();
services2.add(new Camera());
services2.add(new Factory(services2));
services2.add(map);
final Handler handler2 = services2.add(new Handler(services2));
final HandlerPersister persister2 = new HandlerPersister(services2);
try (FileReading reading = new FileReading(media)) {
persister2.load(reading);
}
handler2.update(1.0);
final Featurable featurable2 = handler2.values().iterator().next();
final Transformable transformable = featurable2.getFeature(Transformable.class);
assertEquals(16.0, transformable.getX());
assertEquals(32.0, transformable.getY());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class Scene method update.
@Override
public void update(double extrp) {
tick.update(extrp);
tickGen.update(extrp);
if (tickGen.elapsed(10L)) {
final MapTile generated = generator.generateMap(parameters, Arrays.asList(Medias.create("forest.png")), Medias.create("sheets.xml"), Medias.create("groups.xml"));
append.append(generated, 0, 0);
tickGen.restart();
}
if (tick.elapsed(40L)) {
end();
}
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTileCircuitModelTest method testTransitive.
/**
* Test the map circuit resolution with transitive.
*/
@Test
void testTransitive() {
final MapTile map = createMap(TILE_WATER);
final MapTileGroup mapGroup = map.getFeature(MapTileGroup.class);
final MapTileCircuit mapCircuit = map.getFeature(MapTileCircuitModel.class);
map.setTile(5, 5, TILE_ROAD);
final Tile newTile = map.getTile(5, 5);
mapCircuit.resolve(newTile);
assertEquals(ROAD, mapGroup.getGroup(map.getTile(5, 5)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(4, 4)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(5, 4)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(6, 4)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(4, 5)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(6, 5)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(4, 6)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(5, 6)));
assertEquals(TRANSITION, mapGroup.getGroup(map.getTile(6, 6)));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTileCircuitModelTest method createMap.
/**
* Create the map and configure it.
*
* @param tileNumber The number to fill.
* @return The configured map.
*/
private static MapTile createMap(int tileNumber) {
final MapTile map = UtilMap.createMap(8);
map.getFeature(MapTileTransition.class).loadTransitions(configTransitions);
map.getFeature(MapTileCircuit.class).loadCircuits(configCircuits);
UtilMap.fill(map, tileNumber);
return map;
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class TransitionsExtractorTest method createMap.
/**
* Create the map and configure it.
*
* @param services The services reference.
* @param setup The setup.
* @param tileNumber The number to fill.
* @return The configured map.
*/
private static MapTile createMap(Services services, Setup setup, int tileNumber) {
final MapTile map = UtilMap.createMap(tileNumber);
map.getFeature(MapTileTransition.class).loadTransitions(config);
return map;
}
Aggregations