New geometry data structures.
This commit is contained in:
36
src/render.c
36
src/render.c
@@ -3,12 +3,18 @@
|
||||
|
||||
#include <raylib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Vector2 PointToVector2(Pt p) {
|
||||
Vector2 v;
|
||||
v.x = (float)(p.x * 100) + 50;
|
||||
v.y = (float)(p.y * 100) + 50;
|
||||
v.x = (float)(p.x * 100) + 50.;
|
||||
v.y = (float)(p.y * 100) + 50.;
|
||||
return v;
|
||||
}
|
||||
|
||||
Vector2 PointpToVector2(Pt* p) {
|
||||
Vector2 v;
|
||||
v.x = (float)(p->x * 100) + 50;
|
||||
v.y = (float)(p->y * 100) + 50;
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -16,23 +22,13 @@ void render() {
|
||||
for (int i = 0; i < NPLATES; i++) {
|
||||
Plate plate = lith[i];
|
||||
|
||||
// Skip plates with less than 3 vertices (can't form a polygon).
|
||||
if (plate.nverts < 3) continue;
|
||||
|
||||
// Convert the vertices from world coordinates (Pt) to screen
|
||||
// coordinates (Vector2).
|
||||
Vector2 screen_verts[10];
|
||||
for (int j = 0; j < plate.nverts; j++) {
|
||||
screen_verts[j] = PointToVector2(plate.verts[j]);
|
||||
}
|
||||
|
||||
for (int j = 0; j < plate.nverts; j++) {
|
||||
Vector2 p1 = screen_verts[j];
|
||||
Vector2 p2 =
|
||||
screen_verts[(j + 1) % plate.nverts]; // Loop back to the first
|
||||
// point
|
||||
DrawLineV(p1, p2, WHITE);
|
||||
}
|
||||
DrawTriangleLines(
|
||||
PointToVector2(plate.tris[0].a), PointToVector2(plate.tris[0].b),
|
||||
PointToVector2(plate.tris[0].c), RED
|
||||
);
|
||||
printf(
|
||||
">>>>>>>>>>>>>>>>>>%i %i\n", plate.tris[0].a.x, plate.tris[0].a.y
|
||||
);
|
||||
}
|
||||
|
||||
for (int x = 0; x < WORLD_SZ; x++) {
|
||||
|
||||
Reference in New Issue
Block a user