use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class UtilExtractable method createExtractable.
/**
* Create extractable.
*
* @return The extractable.
*/
public static Extractable createExtractable() {
final Services services = new Services();
services.add(new MapTileGame());
final Featurable featurable = new FeaturableModel();
featurable.addFeature(new IdentifiableModel());
featurable.addFeature(new TransformableModel());
final Extractable extractable = new ExtractableModel(services);
extractable.setResourcesQuantity(10);
extractable.setResourcesType(ResourceType.WOOD);
extractable.prepare(featurable);
return extractable;
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class TransitionConfigTest method testExportsImports.
/**
* Test exports and imports.
*
* @throws IOException If error.
*/
@Test
public void testExportsImports() throws IOException {
final MapTile map = UtilMap.createMap(7);
UtilMap.fill(map, UtilMap.TILE_WATER);
UtilMap.fill(map, UtilMap.TILE_WATER, UtilMap.TILE_TRANSITION, 3);
final MapTile map2 = UtilMap.createMap(7);
UtilMap.fill(map, UtilMap.TILE_WATER);
UtilMap.fill(map, UtilMap.TILE_GROUND, UtilMap.TILE_TRANSITION, 3);
final MapTile map3 = new MapTileGame();
map3.addFeature(new MapTileGroupModel());
map3.create(1, 1, 3, 3);
final TransitionsExtractor extractor = new TransitionsExtractorImpl();
final Map<Transition, Collection<TileRef>> transitions = extractor.getTransitions(Arrays.asList(map, map2, map3));
final Media media = Medias.create("transition.xml");
TransitionsConfig.exports(media, transitions);
Assert.assertEquals(transitions, TransitionsConfig.imports(media));
Assert.assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame in project lionengine by b3dgs.
the class Scene method load.
@Override
public void load() {
final MapTileGame map = services.create(MapTileGame.class);
map.create(Medias.create("level.png"));
final Camera camera = services.create(Camera.class);
camera.setIntervals(16, 0);
camera.setView(0, 0, getWidth(), getHeight(), getHeight());
camera.setLimits(map);
handler.add(camera);
final MapTileGroup mapGroup = map.addFeatureAndGet(new MapTileGroupModel());
final MapTileCollision mapCollision = map.addFeatureAndGet(new MapTileCollisionModel());
mapCollisionRenderer = map.addFeatureAndGet(new MapTileCollisionRendererModel());
handler.add(map);
mapGroup.loadGroups(Medias.create("groups.xml"));
mapCollision.loadCollisions(Medias.create("formulas.xml"), Medias.create("collisions.xml"));
mapCollisionRenderer.createCollisionDraw();
final MapTileViewer mapViewer = map.addFeatureAndGet(new MapTileViewerModel(services));
mapViewer.addRenderer(mapCollisionRenderer);
mapViewer.prepare(map);
final Factory factory = services.create(Factory.class);
final Mario mario = factory.create(Mario.MEDIA);
mario.getFeature(Transformable.class).teleport(400, 31);
handler.add(mario);
final CameraTracker tracker = new CameraTracker(services);
tracker.track(mario);
handler.add(tracker);
clear.start();
tick.start();
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTileGame 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.MapTileGame in project lionengine by b3dgs.
the class CollisionGroupConfigTest method prepare.
/**
* Prepare test.
*/
@BeforeEach
public void prepare() {
final MapTileGame map = new MapTileGame();
map.addFeature(new MapTileGroupModel());
mapCollision = new MapTileCollisionModel();
mapCollision.prepare(map);
}
Aggregations