-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsp.h
85 lines (56 loc) · 1.18 KB
/
bsp.h
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
75
76
77
78
79
80
81
82
83
84
85
#ifndef _BSP_
#define _BSP_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "rng.h"
#include "vec2.h"
enum
{
e_BspParameter_Iterations = 0,
e_BspParameter_RoomSize,
e_BspParameter_MinRoomSize,
e_BspParameter_RoomOffset,
e_BspParameter_RoomChance,
e_BspParameter_RectOffset,
e_BspParameter_CorridorWidth,
e_BspParameter_NumCorridors,
e_BspParameter_SIZE_
};
static const char *bsp_parameter_keys[] = {
"iterations",
"roomSize",
"minRoomSize",
"roomOffset",
"roomChance",
"rectOffset",
"corridorWidth",
"numCorridors"
};
typedef struct Room
{
Vec2 pos;
int width;
int height;
int num;
Vec2 center;
struct Room *next;
} Room;
typedef struct Rect
{
Vec2 pos;
int width;
int height;
Vec2 split;
Room *room;
struct Rect *parent;
struct Rect *childLeft;
struct Rect *childRight;
} Rect;
void bsp_set_debug ();
void bsp_set_parameters (int *const parameters);
Rect *rect_create (Rect *const, const Vec2, const int, const int);
void bsp (Rect **rect, const int iteration, const int offset);
void Rect_free (Rect *rect);
#endif