Skip to content

Commit

Permalink
#79: Improved BiomeController.
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Jun 2, 2019
1 parent c41f55c commit deed512
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion FantasyWorldSimulation/docs/design/map/polygons-vs-grid.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
** Changes to smaller areas can be tracked
** Changes to sea level affect smaller areas
* Faster map generation
* Fixed Number of neighbors
* Fixed layout
** Fixed Number of neighbors
** Fast look up of cell at a position

|===
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ enum SelectedFeature {

private ImageBasedVoronoiDiagram<Void, Void, WorldCell> voronoiDiagram = new ImageBasedVoronoiDiagram<>(Rectangle.fromSize(SIZE), 2);

private int pixelsPerCell = 1;
private int cellMapWidth = 800;
private int cellMapHeight = 600;
private CellMap2d<WorldCell> cellMap;
Expand Down Expand Up @@ -140,6 +141,8 @@ private Mesh<Void, Void, WorldCell> initVoronoiDiagram() {
}

private void createCellMap() {
cellMapWidth = (int) (SIZE.getX() / (double)pixelsPerCell);
cellMapHeight = (int) (SIZE.getY() / (double)pixelsPerCell);
int numberOfCells = cellMapWidth * cellMapHeight;
WorldCell[] cells = new WorldCell[numberOfCells];

Expand All @@ -148,7 +151,7 @@ private void createCellMap() {
}

cellMap = new ArrayCellMap2D<>(cellMapWidth, cellMapHeight, cells);
mapper = new ToCellMapper<>(cellMap, 1.0);
mapper = new ToCellMapper<>(cellMap, pixelsPerCell);
}

private void generateElevation(Mesh<Void, Void, WorldCell> mesh) {
Expand Down Expand Up @@ -227,7 +230,7 @@ public void render() {

if(selectedMapType == SelectedMapType.GRID) {
WritableImage image = imageRenderer.render(cellMap, colorSelector);
mapCanvas.getGraphicsContext2D().drawImage(image, 0, 0);
mapCanvas.getGraphicsContext2D().drawImage(image, 0, 0, SIZE.getX(), SIZE.getY());
}
else {
meshRenderer.renderFaces(voronoiDiagram.getMesh(), colorSelector);
Expand Down

0 comments on commit deed512

Please sign in to comment.