use of com.b3dgs.lionengine.game.feature.tile.Tile 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.Tile 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.Tile in project lionengine by b3dgs.
the class MapTileFog method updateFov.
/**
* Update fovable field of view (fog of war).
*
* @param fovable The fovable reference.
*/
private void updateFov(Fovable fovable) {
final int tx = fovable.getInTileX();
final int ty = fovable.getInTileY();
final int tw = fovable.getInTileWidth();
final int th = fovable.getInTileHeight();
final int ray = fovable.getInTileFov();
final int sx = UtilMath.clamp(tx - ray - tw / 2, 0, map.getInTileWidth() - 1);
final int ex = UtilMath.clamp(tx + ray + tw / 2, 0, map.getInTileWidth() - 1);
final int sy = UtilMath.clamp(ty - ray - th / 2, 0, map.getInTileHeight() - 1);
final int ey = UtilMath.clamp(ty + ray + th / 2, 0, map.getInTileHeight() - 1);
for (int x = sx + 1; x < ex; x++) {
for (int y = sy + 1; y < ey; y++) {
final Tile tile = new TileGame(Integer.valueOf(0), NO_FOG, x * map.getTileWidth(), y * map.getTileHeight(), map.getTileWidth(), map.getTileHeight());
map.setTile(tile);
transition.resolve(getTile(x, y));
}
}
for (int x = sx; x < ex + 1; x++) {
for (int y = sy; y < ey + 1; y++) {
final Tile tile = map.getTile(x, y);
revealed.add(tile);
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class LevelRipConverter method checkPixel.
/**
* Check the pixel by searching tile on sheet.
*
* @param map The destination map reference.
* @param tileRef The tile sheet.
* @param progressTileX The progress on horizontal tiles.
* @param progressTileY The progress on vertical tiles.
* @return <code>true</code> if tile found, <code>false</code> else.
*/
private static boolean checkPixel(MapTile map, ImageBuffer tileRef, int progressTileX, int progressTileY) {
final int x = progressTileX * map.getTileWidth();
final int y = progressTileY * map.getTileHeight();
final int pixel = tileRef.getRgb(x, y);
// Skip blank tile of image map
if (TilesExtractor.IGNORED_COLOR_VALUE != pixel) {
// Search if tile is on sheet and get it
final Tile tile = searchForTile(map, tileRef, progressTileX, progressTileY);
if (tile == null) {
return false;
}
map.setTile(tile);
}
return true;
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTileGame method appendMap.
/**
* Append the map at specified offset.
*
* @param map The map to append.
* @param offsetX The horizontal offset.
* @param offsetY The vertical offset.
*/
private void appendMap(MapTile map, int offsetX, int offsetY) {
for (int v = 0; v < map.getInTileHeight(); v++) {
final int ty = offsetY + v;
for (int h = 0; h < map.getInTileWidth(); h++) {
final int tx = offsetX + h;
final Tile tile = map.getTile(h, v);
if (tile != null) {
final double x = tx * (double) tileWidth;
final double y = ty * (double) tileHeight;
setTile(createTile(tile.getSheet(), tile.getNumber(), x, y));
}
}
}
}
Aggregations