-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.c
51 lines (47 loc) · 1.21 KB
/
utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "utils.h"
#include <stdio.h>
void printVec2(const Vec2* vec)
{
printf("x: %f, y: %f\n", vec->x, vec->y);
}
static void printGeo(const Geo* geo, const Vertex* buffer)
{
printf("Vertex count: %d\n", geo->vertCount);
for (int i = 0; i < geo->vertCount; i++)
{
printf("Vertex %d: ", i);
printVec2(buffer + geo->vertIndex + i);
}
}
void printWorld()
{
printf("World info:\n");
printf("World has %d active objects.\n", w_ObjectCount);
for (int i = 0; i < w_ObjectCount; i++)
{
const W_Object* obj = &w_Objects[i];
printf("Object %d:\n", i);
printf("Pos: ");
printVec2(&obj->pos);
printf("Vel: ");
printVec2(&obj->vel);
printf("Accel: ");
printVec2(&obj->accel);
printf("Angle: %f\n", obj->angle);
printf("Mass: %f\n", obj->mass);
printf("Geo: ");
printGeo(&w_Geos[i], w_ObjectVertexBuffer);
}
}
void bitprint(const void* const thing, const size_t bitcount)
{
int mask;
for (int i = bitcount - 1; i >= 0; i--) {
mask = 1 << i;
if (mask & *(int*)thing)
putchar('1');
else
putchar('0');
}
putchar('\n');
}