@@ -711,6 +711,26 @@ Dictionary TerrainGen::generate(
711711 tile's for each cell
712712
713713 *****************************************************/
714+ for (int x = 0 ; x < width; x++) {
715+ for (int y = 0 ; y < height; y++) {
716+ int n1 = heightMap[x][y];
717+ int n2 = heightMap[x + 1 ][y];
718+ int n3 = heightMap[x][y + 1 ];
719+ int n4 = heightMap[x + 1 ][y + 1 ];
720+
721+ // Determine the Elevation Value
722+ //
723+ // Elevation of tile is the max of the neighbors elevation,
724+ // assuming that the random noise is consistent in its spread
725+ //
726+ int elevation = max ({ n1, n2, n3, n4 });
727+
728+ if (elevation == 0 ) { // Water Tiles are considered the same elevation as Ground
729+ elevation = 1 ;
730+ }
731+ elevationMap[x][y] = elevation;
732+ }
733+ }
714734
715735 // Loop over all the grid cells
716736 for (int x = 0 ; x < width; x++) {
@@ -731,13 +751,6 @@ Dictionary TerrainGen::generate(
731751 int n3 = heightMap[x][y + 1 ];
732752 int n4 = heightMap[x + 1 ][y + 1 ];
733753
734- // Determine the Elevation Value
735- //
736- // Elevation of tile is the max of the neighbors elevation,
737- // assuming that the random noise is consistent in its spread
738- //
739- int elevation = max ({ n1, n2, n3, n4 });
740-
741754 // Determine the Slope from Raw Noise
742755 //
743756 // Use slope to determine Cliffs & Ramps
@@ -844,7 +857,7 @@ Dictionary TerrainGen::generate(
844857 // Water Corners
845858 // -------------------------//
846859
847- // Water's Corner West
860+ // Water's Corner WEST
848861 // +----+----+ +---+---+
849862 // | n1 | n2 | | 0 | 0 |
850863 // +----+----+ +---+---+
@@ -855,7 +868,7 @@ Dictionary TerrainGen::generate(
855868 tileMap[x][y] = WATER_CORNER;
856869 tilesRotation = WEST;
857870 }
858- // Water's Corner East
871+ // Water's Corner EAST
859872 // +----+----+ +---+---+
860873 // | n1 | n2 | | 1 | 0 |
861874 // +----+----+ +---+---+
@@ -866,7 +879,7 @@ Dictionary TerrainGen::generate(
866879 tileMap[x][y] = WATER_CORNER;
867880 tilesRotation = EAST;
868881 }
869- // Water's Corner South
882+ // Water's Corner SOUTH
870883 // +----+----+ +---+---+
871884 // | n1 | n2 | | 0 | 1 |
872885 // +----+----+ +---+---+
@@ -877,7 +890,7 @@ Dictionary TerrainGen::generate(
877890 tileMap[x][y] = WATER_CORNER;
878891 tilesRotation = SOUTH;
879892 }
880- // Water's Corner North
893+ // Water's Corner NORTH
881894 // +----+----+ +---+---+
882895 // | n1 | n2 | | 0 | 0 |
883896 // +----+----+ +---+---+
@@ -893,7 +906,7 @@ Dictionary TerrainGen::generate(
893906 // Cliff's & Ramp's Corner
894907 // -------------------------//
895908
896- // Corner East
909+ // Corner EAST
897910 // +----+----+ +---+---+
898911 // | n1 | n2 | | 1 | 1 |
899912 // +----+----+ +---+---+
@@ -909,7 +922,7 @@ Dictionary TerrainGen::generate(
909922 }
910923 tilesRotation = EAST;
911924 }
912- // Corner West
925+ // Corner WEST
913926 // +----+----+ +---+---+
914927 // | n1 | n2 | | 2 | 1 |
915928 // +----+----+ +---+---+
@@ -925,7 +938,7 @@ Dictionary TerrainGen::generate(
925938 }
926939 tilesRotation = WEST;
927940 }
928- // Corner North
941+ // Corner NORTH
929942 // +----+----+ +---+---+
930943 // | n1 | n2 | | 1 | 2 |
931944 // +----+----+ +---+---+
@@ -941,7 +954,7 @@ Dictionary TerrainGen::generate(
941954 }
942955 tilesRotation = NORTH;
943956 }
944- // Corner South
957+ // Corner SOUTH
945958 // +----+----+ +---+---+
946959 // | n1 | n2 | | 0 | 0 |
947960 // +----+----+ +---+---+
@@ -962,7 +975,15 @@ Dictionary TerrainGen::generate(
962975 // Cliff's & Ramp's Edges
963976 // -------------------------//
964977
965- // Cliff or Ramp Edge West
978+ // Tile Start
979+ // No Rotation -> North
980+ // +----+----+ +---+---+
981+ // | n1 | n2 | | 1 | 2 |
982+ // +----+----+ +---+---+
983+ // | n3 | n4 | | 1 | 2 |
984+ // +----+----+ +---+---+
985+
986+ // Cliff or Ramp Edge EAST
966987 // +----+----+ +---+---+
967988 // | n1 | n2 | | 1 | 1 |
968989 // +----+----+ +---+---+
@@ -976,9 +997,18 @@ Dictionary TerrainGen::generate(
976997 } else {
977998 tileMap[x][y] = RAMP;
978999 }
979- tilesRotation = WEST ;
1000+ tilesRotation = EAST ;
9801001 }
981- // Cliff's Edge East
1002+ //
1003+ // Tile Start
1004+ // No Rotation -> North
1005+ // +----+----+ +---+---+
1006+ // | n1 | n2 | | 1 | 2 |
1007+ // +----+----+ +---+---+
1008+ // | n3 | n4 | | 1 | 2 |
1009+ // +----+----+ +---+---+
1010+ //
1011+ // Cliff's Edge WEST
9821012 // +----+----+ +---+---+
9831013 // | n1 | n2 | | 2 | 2 |
9841014 // +----+----+ +---+---+
@@ -992,9 +1022,18 @@ Dictionary TerrainGen::generate(
9921022 } else {
9931023 tileMap[x][y] = RAMP;
9941024 }
995- tilesRotation = EAST ;
1025+ tilesRotation = WEST ;
9961026 }
997- // Cliff's Edge North
1027+ //
1028+ // Tile Start
1029+ // No Rotation -> North
1030+ // +----+----+ +---+---+
1031+ // | n1 | n2 | | 1 | 2 |
1032+ // +----+----+ +---+---+
1033+ // | n3 | n4 | | 1 | 2 |
1034+ // +----+----+ +---+---+
1035+ //
1036+ // Cliff's Edge SOUTH
9981037 // +----+----+ +---+---+
9991038 // | n1 | n2 | | 2 | 1 |
10001039 // +----+----+ +---+---+
@@ -1008,9 +1047,18 @@ Dictionary TerrainGen::generate(
10081047 } else {
10091048 tileMap[x][y] = RAMP;
10101049 }
1011- tilesRotation = NORTH ;
1050+ tilesRotation = SOUTH ;
10121051 }
1013- // Cliff's Edge South
1052+ //
1053+ // Tile Start
1054+ // No Rotation -> North
1055+ // +----+----+ +---+---+
1056+ // | n1 | n2 | | 1 | 2 |
1057+ // +----+----+ +---+---+
1058+ // | n3 | n4 | | 1 | 2 |
1059+ // +----+----+ +---+---+
1060+ //
1061+ // Cliff's Edge NORTH
10141062 // +----+----+ +---+---+
10151063 // | n1 | n2 | | 1 | 2 |
10161064 // +----+----+ +---+---+
@@ -1024,16 +1072,16 @@ Dictionary TerrainGen::generate(
10241072 } else {
10251073 tileMap[x][y] = RAMP;
10261074 }
1027- tilesRotation = SOUTH ;
1075+ tilesRotation = NORTH ;
10281076 }
10291077
10301078 /* ****************************************************
10311079
10321080 Grid Map Cell Setter
10331081
10341082 *****************************************************/
1035- elevationMap[x][y] = elevation;
1036- myGridMap->set_cell_item (Vector3i (x, elevation , y), tileMap[x][y], tilesRotation);
1083+
1084+ myGridMap->set_cell_item (Vector3i (x, elevationMap[x][y] , y), tileMap[x][y], tilesRotation);
10371085 }
10381086 }
10391087
0 commit comments