use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class TransitiveGroup method checkTransitives.
/**
* Check transitive tiles.
*
* @param tile The tile reference.
* @param tx The horizontal index neighbor.
* @param ty The vertical index neighbor.
*/
private void checkTransitives(Tile tile, int tx, int ty) {
final Tile neighbor = map.getTile(tx, ty);
final String group = mapGroup.getGroup(neighbor);
if (neighbor != null) {
for (final GroupTransition current : getTransitives(mapGroup.getGroup(tile), mapGroup.getGroup(neighbor))) {
for (final Integer number : mapGroup.getGroup(current.getOut())) {
checkTransitives(neighbor, group, current, number);
}
break;
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTileViewerModel method renderTile.
/**
* Render the tile from location.
*
* @param g The graphic output.
* @param tx The horizontal tile location.
* @param ty The vertical tile location.
* @param viewX The horizontal view offset.
* @param viewY The vertical view offset.
*/
private void renderTile(Graphic g, int tx, int ty, double viewX, double viewY) {
final Tile tile = map.getTile(tx, ty);
if (tile != null) {
final int x = (int) Math.round(tile.getX() - viewX);
final int y = (int) Math.round(-tile.getY() + viewY - tile.getHeight());
for (int i = 0; i < renderers.size(); i++) {
renderers.get(i).renderTile(g, tile, x, y);
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class MapTileGameTest method testSetGetTile.
/**
* Test map set and get tile.
*/
@Test
void testSetGetTile() {
map.create(16, 16, 3, 3);
map.loadSheets(new ArrayList<SpriteTiled>());
assertEquals(0, map.getTilesNumber());
assertNull(map.getTile(0, 0));
assertNull(map.getTileAt(51.0, 68.0));
map.setTile(0, 0, 0);
final Tile tile = map.getTile(0, 0);
assertEquals(1, map.getTilesNumber());
assertEquals(tile, map.getTile(0, 0));
assertEquals(tile, map.getTile(Geom.createLocalizable(0, 0), 0, 0));
assertEquals(tile, map.getTileAt(3.0, 6.0));
assertEquals(Arrays.asList(tile), map.getTilesHit(-1, -1, 1, 1));
}
use of com.b3dgs.lionengine.game.feature.tile.Tile in project lionengine by b3dgs.
the class CollisionResultTest method testNoResult.
/**
* Test the collision no result.
*/
@Test
void testNoResult() {
final Tile tile = new TileGame(1, 3, 4, 1, 1);
CollisionResult result = new CollisionResult(null, null, tile, null, null);
assertFalse(result.startWithX("formula"));
assertFalse(result.startWithY("formulaZ"));
assertFalse(result.contains("formula"));
result = new CollisionResult(null, null, tile, formulaX, null);
assertTrue(result.startWithX("formula"));
assertFalse(result.startWithX("formulaZ"));
assertFalse(result.startWithY("formula"));
assertFalse(result.startWithY("formulaZ"));
assertTrue(result.contains("formula"));
assertFalse(result.contains("formulaZ"));
result = new CollisionResult(null, null, tile, null, formulaY);
assertFalse(result.startWithX("formula"));
assertFalse(result.startWithX("formulaZ"));
assertTrue(result.startWithY("formula"));
assertFalse(result.startWithY("formulaZ"));
assertTrue(result.contains("formula"));
assertFalse(result.contains("formulaZ"));
}
Aggregations