Plate generation.
This commit is contained in:
52
src/gen.c
52
src/gen.c
@@ -1,6 +1,9 @@
|
||||
#include "include/gen.h"
|
||||
#include "include/col.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
Vec2 asth[WORLD_SZ][WORLD_SZ] = {
|
||||
{
|
||||
(Vec2){.x = 1, .y = 2},
|
||||
@@ -84,10 +87,45 @@ Vec2 asth[WORLD_SZ][WORLD_SZ] = {
|
||||
},
|
||||
};
|
||||
|
||||
Plate lith[NPLATES] = {
|
||||
(Plate){.col = COL_BLU,
|
||||
.nverts = 4,
|
||||
.verts = {(Pt){0, 0}, (Pt){7, 0}, (Pt){7, 5}, (Pt){4, 4}}},
|
||||
(Plate){COL_RED, 4, {(Pt){0, 0}, (Pt){4, 4}, (Pt){2, 7}, (Pt){0, 7}}},
|
||||
(Plate){COL_GRN, 4, {(Pt){4, 4}, (Pt){7, 5}, (Pt){7, 7}, (Pt){2, 7}}},
|
||||
};
|
||||
Plate lith[NPLATES];
|
||||
|
||||
// Find the point for an index to the edge of the world.
|
||||
Pt world_edge_idx_to_pt(int idx) {
|
||||
if (0 <= idx && idx < 8) {
|
||||
return (Pt){idx, 0};
|
||||
} else if (8 <= idx && idx < 16) {
|
||||
return (Pt){7, idx - 8};
|
||||
} else if (16 <= idx && idx < 24) {
|
||||
return (Pt){idx - 16, 0};
|
||||
} else if (24 <= idx && idx < 32) {
|
||||
return (Pt){7, idx - 24};
|
||||
} else {
|
||||
exit(122);
|
||||
}
|
||||
}
|
||||
|
||||
void gen_lith() {
|
||||
srand(time(NULL));
|
||||
|
||||
Pt p1 = {(rand() % 6) + 1, 0};
|
||||
Pt p2 = {(rand() % 6) + 1, 7};
|
||||
|
||||
lith[0] = (Plate){
|
||||
.col = COL_RED,
|
||||
.nverts = 4,
|
||||
.verts = {
|
||||
(Pt){0, 0},
|
||||
p1,
|
||||
p2,
|
||||
(Pt){0, 7},
|
||||
},
|
||||
};
|
||||
lith[1] = (Plate){.col = COL_RED,
|
||||
.nverts = 4,
|
||||
.verts = {
|
||||
p1,
|
||||
(Pt){7, 0},
|
||||
(Pt){7, 7},
|
||||
p2,
|
||||
}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user