use of com.almasb.fxgl.procedural.BiomeMapGenerator in project FXGL by AlmasB.
the class MapGenerationSample method plain.
private void plain() {
// tile size
int size = 5;
int W = (getAppWidth() - 200) / size;
int H = getAppHeight() / size;
Grid<BiomeMapGenerator.BiomeData> map = new Grid<>(BiomeMapGenerator.BiomeData.class, W, H, new BiomeMapGenerator(W, H, 2.4));
map.forEach(cell -> {
Texture texture;
if (cell.getElevation() < 0.2) {
// water
texture = new ColoredTexture(size, size, Color.BLUE);
} else if (cell.getElevation() < 0.8) {
// grass
texture = texture("grass.png", size, size);
} else {
// in-land grass / mud?
texture = texture("grass.png", size, size).desaturate().brighter().desaturate();
}
entityBuilder().at(cell.getX() * size, cell.getY() * size).view(texture).buildAndAttach();
});
}
Aggregations