1313#include " ../structures/Rock.h"
1414#include " ../structures/Cloud.h"
1515#include " ../structures/SnowFlake.h"
16-
17- // #include "../biome/BiomeType.h"
18-
1916#include " ../main.h"
2017
2118using namespace std ;
@@ -123,81 +120,65 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
123120 if (k <= height) {
124121 int water_level = 7 ;
125122
126-
127123 if (k <= water_level) {
128124 this ->blocks [i][water_level][j] = WATER;
129125 } else {
130-
131126 this ->blocks [i][k][j] = this ->biome ->ground ;
127+ string key;
132128
133-
134- std::string key;
135-
136- key = std::to_string (this ->x + 1 ) + " _" + std::to_string (this ->z );
129+ key = to_string (this ->x + 1 ) + " _" + to_string (this ->z );
137130 if (worldPtr->chunks .count (key) > 0 ) {
138131 if (this ->biome != worldPtr->chunks [key]->biome ) {
139132 int random_number = rand () % 100 ;
140-
141133 int prob_actual_next_ground = 0 ;
134+
142135 if (i == CHUNK_SIZE - 1 ) prob_actual_next_ground = 80 ;
143136 if (i == CHUNK_SIZE - 2 ) prob_actual_next_ground = 20 ;
144- // if (i == 2) prob_actual_next_ground = 60;
145- // if (i == 3) prob_actual_next_ground = 80;
146-
147137 if (random_number < prob_actual_next_ground) {
148138 this ->blocks [i][k][j] = worldPtr->chunks [key]->biome ->ground ;
149139 }
150140 }
151141 }
152142
153143
154- key = std:: to_string (this ->x ) + " _" + std:: to_string (this ->z + 1 );
144+ key = to_string (this ->x ) + " _" + to_string (this ->z + 1 );
155145 if (worldPtr->chunks .count (key) > 0 ) {
156146 if (this ->biome != worldPtr->chunks [key]->biome ) {
157147 int random_number = rand () % 100 ;
158-
159148 int prob_actual_next_ground = 0 ;
149+
160150 if (j == CHUNK_SIZE - 1 ) prob_actual_next_ground = 80 ;
161151 if (j == CHUNK_SIZE - 2 ) prob_actual_next_ground = 20 ;
162- // if (j == 2) prob_actual_next_ground = 60;
163- // if (j == 3) prob_actual_next_ground = 80;
164-
165152 if (random_number < prob_actual_next_ground) {
166153 this ->blocks [i][k][j] = worldPtr->chunks [key]->biome ->ground ;
167154 }
168155 }
169156 }
170157
171158
172- key = std:: to_string (this ->x - 1 ) + " _" + std:: to_string (this ->z );
159+ key = to_string (this ->x - 1 ) + " _" + to_string (this ->z );
173160 if (worldPtr->chunks .count (key) > 0 ) {
174161 if (this ->biome != worldPtr->chunks [key]->biome ) {
175162 int random_number = rand () % 100 ;
176-
177163 int prob_actual_next_ground = 0 ;
164+
178165 if (i == 0 ) prob_actual_next_ground = 80 ;
179166 if (i == 1 ) prob_actual_next_ground = 20 ;
180- // if (i == CHUNK_SIZE - 3) prob_actual_next_ground = 60;
181- // if (i == CHUNK_SIZE - 4) prob_actual_next_ground = 80;
182-
183167 if (random_number < prob_actual_next_ground) {
184168 this ->blocks [i][k][j] = worldPtr->chunks [key]->biome ->ground ;
185169 }
186170 }
187171 }
188172
189173
190- key = std:: to_string (this ->x ) + " _" + std:: to_string (this ->z - 1 );
174+ key = to_string (this ->x ) + " _" + to_string (this ->z - 1 );
191175 if (worldPtr->chunks .count (key) > 0 ) {
192176 if (this ->biome != worldPtr->chunks [key]->biome ) {
193177 int random_number = rand () % 100 ;
194-
195178 int prob_actual_next_ground = 0 ;
179+
196180 if (j == 0 ) prob_actual_next_ground = 80 ;
197181 if (j == 1 ) prob_actual_next_ground = 20 ;
198- // if (j == CHUNK_SIZE - 3) prob_actual_next_ground = 60;
199- // if (j == CHUNK_SIZE - 4) prob_actual_next_ground = 80;
200-
201182 if (random_number < prob_actual_next_ground) {
202183 this ->blocks [i][k][j] = worldPtr->chunks [key]->biome ->ground ;
203184 }
@@ -208,31 +189,15 @@ Chunk::Chunk(int chunk_x, int chunk_z, BiomeType *biome) {
208189 }
209190
210191 int snow_level_min = 23 ;
211- // int snow_progress = 15;
212-
213-
214- // int snow = (rand() % (k+1) - snow_level_min) * snow_progress;
215192
216193 if (k > snow_level_min + 3 * sin (0.1 * (i + j))) {
217194 this ->blocks [i][k][j] = SNOW;
218195 }
219-
220-
221- // DEBUG
222- // if (i == 0 || j == 0) {
223- // this->blocks[i][k][j] = GROUND;
224- // }
225-
226-
227-
228-
229196 } else {
230197 if (this ->blocks [i][k][j] != WATER) {
231198 this ->blocks [i][k][j] = AIR;
232199 }
233200 }
234-
235-
236201 }
237202 }
238203 }
0 commit comments