use of com.almasb.fxgl.algorithm.procedural.BiomeMapGenerator in project FXGL by AlmasB.
the class MapGenerationSample method plain.
private void plain() {
// tile size
int size = 5;
int W = getWidth() / size;
int H = getHeight() / size;
MapGenerator<BiomeMapGenerator.BiomeData> gen = new BiomeMapGenerator(2.4);
Grid<BiomeMapGenerator.BiomeData> map = gen.generate(W, H);
map.forEach((data, x, y) -> {
Texture texture;
if (data.getElevation() < 0.2) {
// water
texture = new Texture(new WritableImage(size, size)).replaceColor(Color.TRANSPARENT, Color.BLUE);
} else if (data.getElevation() < 0.8) {
// grass
texture = DSLKt.texture("grass.png", size, size);
} else {
// in-land grass / mud?
texture = DSLKt.texture("grass.png", size, size).desaturate().brighter().desaturate();
}
Entities.builder().at(x * size, y * size).viewFromNode(texture).buildAndAttach();
});
}
Aggregations