use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class PrefMapFill method apply.
/*
* Preference
*/
@Override
public void apply(MapTile map) {
final double tw = map.getTileWidth();
final double th = map.getTileHeight();
for (int tx = 0; tx < map.getInTileWidth(); tx++) {
final double x = tx * tw;
for (int ty = 0; ty < map.getInTileHeight(); ty++) {
final double y = ty * th;
final Tile tile = map.createTile(sheet, number, x, y);
map.setTile(tile);
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class FogOfWar method renderTile.
/*
* MapTileRenderer
*/
@Override
public void renderTile(Graphic g, MapTile map, Tile tile, int x, int y) {
final int tx = tile.getInTileX();
final int ty = tile.getInTileY();
final Tile fogTile = mapFogged.getTile(tx, ty);
if (fogMap && fogTile != null && fogTile.getNumber() != MapTileFog.NO_FOG) {
fogTiles.setLocation(x, y);
fogTiles.setTile(fogTile.getNumber());
fogTiles.render(g);
}
final Tile hideTile = mapHidden.getTile(tx, ty);
if (hideMap && hideTile != null && hideTile.getNumber() != MapTileFog.NO_FOG) {
hideTiles.setTile(hideTile.getNumber());
hideTiles.setLocation(x, y);
hideTiles.render(g);
}
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile in project lionengine by b3dgs.
the class MapTransitionExtractorTest method testDifferentSheet.
/**
* Check the transition with different sheets.
*/
@Test
public void testDifferentSheet() {
final MapTile map = UtilMap.createMap(7);
UtilMap.fill(map, TILE_WATER);
map.setTile(map.createTile(Integer.valueOf(1), TILE_WATER, 3, 3));
Assert.assertNull(get(map, 3, 3));
}
use of com.b3dgs.lionengine.game.feature.tile.map.MapTile 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.MapTile in project lionengine by b3dgs.
the class PrefMapRegion method apply.
/*
* Preference
*/
@Override
public void apply(MapTile map) {
final MapTileTransition mapTransition = map.getFeature(MapTileTransition.class);
final int sx = area.getInTileX();
final int sy = area.getInTileY();
final int ex = UtilMath.clamp(area.getInTileWidth(), 0, map.getInTileWidth() - 1);
final int ey = UtilMath.clamp(area.getInTileHeight(), 0, map.getInTileHeight() - 1);
int remaining = count;
while (remaining > 0) {
final int tx = UtilRandom.getRandomInteger(sx, ex);
final int ty = UtilRandom.getRandomInteger(sy, ey);
final int size = UtilRandom.getRandomInteger(maxSize);
final int halfBottom = (int) Math.floor(size / 2.0);
final int halfTop = (int) Math.ceil(size / 2.0);
for (int ox = -halfBottom; ox < halfTop; ox++) {
for (int oy = -halfBottom; oy < halfTop; oy++) {
final int ntx = UtilMath.clamp(tx + ox, sx, ex);
final int nty = UtilMath.clamp(ty + oy, sy, ey);
final Tile tile = new TileGame(number, ntx, nty, map.getTileWidth(), map.getTileHeight());
map.setTile(tile.getInTileX(), tile.getInTileY(), number);
mapTransition.resolve(tile);
}
}
remaining--;
}
}
Aggregations