@@ -173,6 +173,10 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
173
173
// bool change3left = n3 > n4; // n3 -> n4
174
174
// bool change4up = n2 > n4; // n2 -> n4
175
175
176
+ // -------------------------//
177
+ // Basic Tiles
178
+ // -------------------------//
179
+
176
180
// Water's Water
177
181
// +---+---+
178
182
// | 0 | 0 |
@@ -195,6 +199,10 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
195
199
tileMap[x][y] = GROUND;
196
200
}
197
201
202
+ // -------------------------//
203
+ // Water Edges
204
+ // -------------------------//
205
+
198
206
// Water's Edge South
199
207
// +----+----+ +---+---+
200
208
// | n1 | n2 | | 0 | 0 |
@@ -204,7 +212,7 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
204
212
//
205
213
if (n1 == 0 && n2 == 0 && n3 > 0 && n4 > 0 ) {
206
214
tileMap[x][y] = WATER_EDGE;
207
- tilesRotation = 16 ; // Facing South
215
+ tilesRotation = SOUTH;
208
216
}
209
217
// Water's Edge North
210
218
// +----+----+ +---+---+
@@ -215,7 +223,7 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
215
223
//
216
224
else if (n1 > 0 && n2 > 0 && n3 == 0 && n4 == 0 ) {
217
225
tileMap[x][y] = WATER_EDGE;
218
- tilesRotation = 0 ; // Facing North
226
+ tilesRotation = NORTH;
219
227
}
220
228
// Water's Edge East
221
229
// +----+----+ +---+---+
@@ -226,7 +234,7 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
226
234
//
227
235
else if (n1 == 0 && n3 == 0 && n2 > 0 && n4 > 0 ) {
228
236
tileMap[x][y] = WATER_EDGE;
229
- tilesRotation = 10 ; // Facing East
237
+ tilesRotation = EAST;
230
238
231
239
}
232
240
// Water's Edge West
@@ -238,16 +246,113 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
238
246
//
239
247
else if (n2 == 0 && n4 == 0 && n1 > 0 && n3 > 0 ) {
240
248
tileMap[x][y] = WATER_EDGE;
241
- tilesRotation = 22 ; // Facing West
249
+ tilesRotation = WEST;
242
250
}
243
251
244
- // Water's Corner's
252
+ // -------------------------//
253
+ // Water Corners
254
+ // -------------------------//
255
+
256
+ // Water's Corner North
257
+ // +----+----+ +---+---+
258
+ // | n1 | n2 | | 0 | 0 |
259
+ // +----+----+ +---+---+
260
+ // | n3 | n4 | | 0 | 1 |
261
+ // +----+----+ +---+---+
262
+ //
245
263
if (n1 == 0 && n2 == 0 && n3 == 0 && n4 > 0 ) {
246
- tileMap[x][y] = WATER_CORNER; // Land in SE
247
- } else if (n1 > 0 && n2 == 0 && n3 == 0 && n4 == 0 ) {
248
- tileMap[x][y] = WATER_CORNER; // Land in NW
264
+ tileMap[x][y] = WATER_CORNER;
265
+ tilesRotation = NORTH;
266
+ }
267
+ // Water's Corner South
268
+ // +----+----+ +---+---+
269
+ // | n1 | n2 | | 1 | 0 |
270
+ // +----+----+ +---+---+
271
+ // | n3 | n4 | | 0 | 0 |
272
+ // +----+----+ +---+---+
273
+ //
274
+ else if (n1 > 0 && n2 == 0 && n3 == 0 && n4 == 0 ) {
275
+ tileMap[x][y] = WATER_CORNER;
276
+ tilesRotation = SOUTH;
277
+ }
278
+ // Water's Corner East
279
+ // +----+----+ +---+---+
280
+ // | n1 | n2 | | 0 | 1 |
281
+ // +----+----+ +---+---+
282
+ // | n3 | n4 | | 0 | 0 |
283
+ // +----+----+ +---+---+
284
+ //
285
+ else if (n1 == 0 && n2 > 0 && n3 == 0 && n4 == 0 ) {
286
+ tileMap[x][y] = WATER_CORNER;
287
+ tilesRotation = EAST;
288
+ }
289
+ // Water's Corner West
290
+ // +----+----+ +---+---+
291
+ // | n1 | n2 | | 0 | 0 |
292
+ // +----+----+ +---+---+
293
+ // | n3 | n4 | | 1 | 0 |
294
+ // +----+----+ +---+---+
295
+ //
296
+ else if (n1 == 0 && n2 == 0 && n3 > 0 && n4 == 0 ) {
297
+ tileMap[x][y] = WATER_CORNER;
298
+ tilesRotation = WEST;
249
299
}
250
300
301
+ // -------------------------//
302
+ // Cliff's & Ramp's Corner
303
+ // -------------------------//
304
+
305
+ // TODO : Decide how cliffs vs ramps are picked
306
+
307
+ // Corner North
308
+ // +----+----+ +---+---+
309
+ // | n1 | n2 | | 1 | 1 |
310
+ // +----+----+ +---+---+
311
+ // | n3 | n4 | | 1 | 2 |
312
+ // +----+----+ +---+---+
313
+ //
314
+ if (n1 > 0 && n2 > 0 && n3 > 0 && n4 > 0 && n4 > n1 && n4 > n2 && n4 > n3) {
315
+ tileMap[x][y] = CLIFF_CORNER;
316
+ tilesRotation = NORTH;
317
+ }
318
+ // Corner South
319
+ // +----+----+ +---+---+
320
+ // | n1 | n2 | | 2 | 1 |
321
+ // +----+----+ +---+---+
322
+ // | n3 | n4 | | 1 | 1 |
323
+ // +----+----+ +---+---+
324
+ //
325
+ else if (n1 > 0 && n2 > 0 && n3 > 0 && n4 > 0 && n1 > n2 && n1 > n3 && n1 > n4) {
326
+ tileMap[x][y] = CLIFF_CORNER;
327
+ tilesRotation = SOUTH;
328
+ }
329
+ // Corner East
330
+ // +----+----+ +---+---+
331
+ // | n1 | n2 | | 1 | 2 |
332
+ // +----+----+ +---+---+
333
+ // | n3 | n4 | | 1 | 1 |
334
+ // +----+----+ +---+---+
335
+ //
336
+ else if (n1 > 0 && n2 > 0 && n3 > 0 && n4 > 0 && n2 > n1 && n2 > n3 && n2 > n4) {
337
+ tileMap[x][y] = CLIFF_CORNER;
338
+ tilesRotation = EAST;
339
+ }
340
+ // Corner East
341
+ // +----+----+ +---+---+
342
+ // | n1 | n2 | | 0 | 0 |
343
+ // +----+----+ +---+---+
344
+ // | n3 | n4 | | 1 | 0 |
345
+ // +----+----+ +---+---+
346
+ //
347
+ else if (n1 > 0 && n2 > 0 && n3 > 0 && n4 > 0 && n3 > n1 && n3 > n2 && n3 > n4) {
348
+ tileMap[x][y] = CLIFF_CORNER;
349
+ tilesRotation = WEST;
350
+ }
351
+
352
+ // -------------------------//
353
+ // Cliff's & Ramp's Edges
354
+ // -------------------------//
355
+
251
356
// Cliff's Edge
252
357
// +----+----+ +---+---+
253
358
// | n1 | n2 | | 2 | 1 |
@@ -417,13 +522,15 @@ void TerrainGen::generate(GridMap *myGridMap, int height, int width, int depth,
417
522
418
523
/* ****************************************************
419
524
420
- Grid Map Cell Setter
525
+ Grid Map Cell Setter
421
526
422
- *****************************************************/
527
+ *****************************************************/
423
528
424
529
myGridMap->set_cell_item (Vector3i (x, elevation, y), tileMap[x][y], rotationOrientation);
425
530
}
426
531
}
532
+
533
+ // TODO : Another run through required to check adjacent tiles, especially tiles touching corner tiles. TO ensure a cliff corner connects to cliffs
427
534
}
428
535
429
536
TerrainGen::TileType TerrainGen::isCornerTile (int x, int y, vector<vector<TileType>> &tileMap) {
0 commit comments