use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTileCollisionModel method applyConstraints.
/**
* Apply tile constraints depending of their adjacent collisions.
*/
private void applyConstraints() {
final Map<Tile, Collection<CollisionFormula>> toRemove = new HashMap<>();
for (int v = 0; v < map.getInTileHeight(); v++) {
for (int h = 0; h < map.getInTileWidth(); h++) {
final Tile tile = map.getTile(h, v);
if (tile != null) {
final TileCollision tileCollision = tile.getFeature(TileCollision.class);
toRemove.put(tile, checkConstraints(tileCollision, h, v));
}
}
}
for (final Entry<Tile, Collection<CollisionFormula>> current : toRemove.entrySet()) {
final Tile tile = current.getKey();
final TileCollision tileCollision = tile.getFeature(TileCollision.class);
for (final CollisionFormula formula : current.getValue()) {
tileCollision.removeCollisionFormula(formula);
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTilePathModel method addObjectId.
@Override
public void addObjectId(int tx, int ty, Integer id) {
final Tile tile = map.getTile(tx, ty);
if (tile != null) {
final TilePath tilePath = tile.getFeature(TilePath.class);
tilePath.addObjectId(id);
}
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class UtilMap method fill.
/**
* Fill map with center tiles from group.
*
* @param map The map reference.
* @param number The tile number.
*/
public static void fill(MapTile map, int number) {
for (int tx = 0; tx < map.getInTileWidth(); tx++) {
for (int ty = 0; ty < map.getInTileHeight(); ty++) {
final Tile tile = map.createTile(SHEET, number, tx, ty);
map.setTile(tile);
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTileGameTest method testClear.
/**
* Test the map clearing.
*/
@Test
public void testClear() {
map.create(16, 16, 2, 2);
final Tile tile = map.createTile(Integer.valueOf(0), 0, 0, 0);
map.setTile(tile);
Assert.assertEquals(tile, map.getTile(0, 0));
map.clear();
Assert.assertNull(map.getTile(0, 0));
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTileAppenderModel method appendMap.
/**
* Append the map at specified offset.
*
* @param other The map to append.
* @param offsetX The horizontal offset.
* @param offsetY The vertical offset.
*/
private void appendMap(MapTile other, int offsetX, int offsetY) {
for (int v = 0; v < other.getInTileHeight(); v++) {
final int ty = offsetY + v;
for (int h = 0; h < other.getInTileWidth(); h++) {
final int tx = offsetX + h;
final Tile tile = other.getTile(h, v);
if (tile != null) {
map.setTile(tx, ty, tile.getNumber());
}
}
}
}
Aggregations