@@ -711,6 +711,26 @@ Dictionary TerrainGen::generate(
711
711
tile's for each cell
712
712
713
713
*****************************************************/
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
+ }
714
734
715
735
// Loop over all the grid cells
716
736
for (int x = 0 ; x < width; x++) {
@@ -731,13 +751,6 @@ Dictionary TerrainGen::generate(
731
751
int n3 = heightMap[x][y + 1 ];
732
752
int n4 = heightMap[x + 1 ][y + 1 ];
733
753
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
-
741
754
// Determine the Slope from Raw Noise
742
755
//
743
756
// Use slope to determine Cliffs & Ramps
@@ -844,7 +857,7 @@ Dictionary TerrainGen::generate(
844
857
// Water Corners
845
858
// -------------------------//
846
859
847
- // Water's Corner West
860
+ // Water's Corner WEST
848
861
// +----+----+ +---+---+
849
862
// | n1 | n2 | | 0 | 0 |
850
863
// +----+----+ +---+---+
@@ -855,7 +868,7 @@ Dictionary TerrainGen::generate(
855
868
tileMap[x][y] = WATER_CORNER;
856
869
tilesRotation = WEST;
857
870
}
858
- // Water's Corner East
871
+ // Water's Corner EAST
859
872
// +----+----+ +---+---+
860
873
// | n1 | n2 | | 1 | 0 |
861
874
// +----+----+ +---+---+
@@ -866,7 +879,7 @@ Dictionary TerrainGen::generate(
866
879
tileMap[x][y] = WATER_CORNER;
867
880
tilesRotation = EAST;
868
881
}
869
- // Water's Corner South
882
+ // Water's Corner SOUTH
870
883
// +----+----+ +---+---+
871
884
// | n1 | n2 | | 0 | 1 |
872
885
// +----+----+ +---+---+
@@ -877,7 +890,7 @@ Dictionary TerrainGen::generate(
877
890
tileMap[x][y] = WATER_CORNER;
878
891
tilesRotation = SOUTH;
879
892
}
880
- // Water's Corner North
893
+ // Water's Corner NORTH
881
894
// +----+----+ +---+---+
882
895
// | n1 | n2 | | 0 | 0 |
883
896
// +----+----+ +---+---+
@@ -893,7 +906,7 @@ Dictionary TerrainGen::generate(
893
906
// Cliff's & Ramp's Corner
894
907
// -------------------------//
895
908
896
- // Corner East
909
+ // Corner EAST
897
910
// +----+----+ +---+---+
898
911
// | n1 | n2 | | 1 | 1 |
899
912
// +----+----+ +---+---+
@@ -909,7 +922,7 @@ Dictionary TerrainGen::generate(
909
922
}
910
923
tilesRotation = EAST;
911
924
}
912
- // Corner West
925
+ // Corner WEST
913
926
// +----+----+ +---+---+
914
927
// | n1 | n2 | | 2 | 1 |
915
928
// +----+----+ +---+---+
@@ -925,7 +938,7 @@ Dictionary TerrainGen::generate(
925
938
}
926
939
tilesRotation = WEST;
927
940
}
928
- // Corner North
941
+ // Corner NORTH
929
942
// +----+----+ +---+---+
930
943
// | n1 | n2 | | 1 | 2 |
931
944
// +----+----+ +---+---+
@@ -941,7 +954,7 @@ Dictionary TerrainGen::generate(
941
954
}
942
955
tilesRotation = NORTH;
943
956
}
944
- // Corner South
957
+ // Corner SOUTH
945
958
// +----+----+ +---+---+
946
959
// | n1 | n2 | | 0 | 0 |
947
960
// +----+----+ +---+---+
@@ -962,7 +975,15 @@ Dictionary TerrainGen::generate(
962
975
// Cliff's & Ramp's Edges
963
976
// -------------------------//
964
977
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
966
987
// +----+----+ +---+---+
967
988
// | n1 | n2 | | 1 | 1 |
968
989
// +----+----+ +---+---+
@@ -976,9 +997,18 @@ Dictionary TerrainGen::generate(
976
997
} else {
977
998
tileMap[x][y] = RAMP;
978
999
}
979
- tilesRotation = WEST ;
1000
+ tilesRotation = EAST ;
980
1001
}
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
982
1012
// +----+----+ +---+---+
983
1013
// | n1 | n2 | | 2 | 2 |
984
1014
// +----+----+ +---+---+
@@ -992,9 +1022,18 @@ Dictionary TerrainGen::generate(
992
1022
} else {
993
1023
tileMap[x][y] = RAMP;
994
1024
}
995
- tilesRotation = EAST ;
1025
+ tilesRotation = WEST ;
996
1026
}
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
998
1037
// +----+----+ +---+---+
999
1038
// | n1 | n2 | | 2 | 1 |
1000
1039
// +----+----+ +---+---+
@@ -1008,9 +1047,18 @@ Dictionary TerrainGen::generate(
1008
1047
} else {
1009
1048
tileMap[x][y] = RAMP;
1010
1049
}
1011
- tilesRotation = NORTH ;
1050
+ tilesRotation = SOUTH ;
1012
1051
}
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
1014
1062
// +----+----+ +---+---+
1015
1063
// | n1 | n2 | | 1 | 2 |
1016
1064
// +----+----+ +---+---+
@@ -1024,16 +1072,16 @@ Dictionary TerrainGen::generate(
1024
1072
} else {
1025
1073
tileMap[x][y] = RAMP;
1026
1074
}
1027
- tilesRotation = SOUTH ;
1075
+ tilesRotation = NORTH ;
1028
1076
}
1029
1077
1030
1078
/* ****************************************************
1031
1079
1032
1080
Grid Map Cell Setter
1033
1081
1034
1082
*****************************************************/
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);
1037
1085
}
1038
1086
}
1039
1087
0 commit comments