summaryrefslogtreecommitdiff
path: root/clld-bench.c
blob: 9fd07cbd5d0569464912257e56772d28acf469e4 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Main Program file.
 *
 * Platform: 	Anything with a C compiler.
 * Author:	mr b0nk 500 <b0nk@mrb0nk500.xyz>
 * Notes: 	Who would even use this kind of collision checker?
 * Created:	September 27, 2019 @ 09:25PM
 */

#include "clld.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
	int colltype = -1;
	/* Create the Cursor, and the Floor */
	struct colis cursor;
	struct colis floor;
	colltype = THM;
	cursor.h = 16;
	cursor.w = 16;
	cursor.pos.x = 17;
	cursor.pos.y = 24;
	cursor.xvel = 1;
	cursor.yvel = 0;
	floor.w = 16;
	floor.h = 16;
	floor.flp = 0;
	int hmpeak;
	if (colltype == THM) {
		floor.heightmap = malloc(sizeof(uint8_t *)*floor.w);
		int i = 0;
		for (; i < floor.w; i++) floor.heightmap[i] = i+1;
		hmpeak = floor.heightmap[floor.w-1];
	}
	uint8_t flt = 0;
	floor.pos.x = 32;
	floor.pos.y = 32;
	floor.xvel = 0;
	floor.yvel = 0;
	if (!flt) {
		cursor.a1 = cursor.pos.x;
		cursor.a2 = cursor.pos.x+cursor.w;
		cursor.b1 = cursor.pos.y;
		cursor.b2 = cursor.pos.y+cursor.h;
		floor.a1  = floor.pos.x;
		floor.a2  = floor.pos.x+floor.w;
		floor.b1  = floor.pos.y;
		floor.b2  = floor.pos.y+floor.h;
	} else {
		cursor.c1 = cursor.pos.fx;
		cursor.c2 = cursor.pos.fx+cursor.w;
		cursor.d1 = cursor.pos.fy;
		cursor.d2 = cursor.pos.fy+cursor.h;
		floor.c1  = floor.pos.fx;
		floor.c2  = floor.pos.fx+floor.w;
		floor.d1  = floor.pos.fy;
		floor.d2  = floor.pos.fy+floor.h;
	}
	switch (colltype) {
		case THM : (!flt) ? thm(hmpeak, &cursor, &floor) : fthm(hmpeak, &cursor, &floor); break; /* Tile Heightmap Collision. */
		case AABB: (!flt) ? aabb(&cursor, &floor       ) : faabb(&cursor, &floor       ); break; /* Axis Aligned Bounding Box Collision. */
	}
	/*uint8_t a = 0;
	unsigned int i = 0;
	free(buf);*/
	if (colltype == THM) {
		free(floor.heightmap);
	}
	fflush(stdout);

	return 0;
}