blob: 40a19f1f39631d7294bfb8074a5964ea1e7e4d65 (
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#ifndef ALL_H
#define ALL_H
#include "raylib.h"
#include "raymath.h"
#include "rlgl.h"
#include "config.h"
// Resolve conflicts between Raylib and nonstd.h
#define Color NS_Color
#include "libraries/nonstd.h"
#undef Color
#include "libraries/vfs.h"
#include <stdbool.h>
#include <stddef.h>
// --- Map Structures ---
typedef struct {
Vector3 p[3];
char texture[64];
float shift[2];
float rotate;
float scale[2];
} MapPlane;
typedef struct {
MapPlane *planes;
int plane_count;
} MapBrush;
typedef struct {
char key[64];
char value[256];
} MapProperty;
typedef struct {
MapProperty *properties;
int property_count;
MapBrush *brushes;
int brush_count;
} MapEntity;
typedef struct {
MapEntity *entities;
int entity_count;
} Map;
typedef struct {
const char *data;
size_t length;
size_t pos;
} MapParser;
typedef struct {
Vector3 normal;
float dist;
} Plane;
typedef struct {
Vector3 *verts;
int count;
} Polygon;
typedef struct {
char texture[64];
array(float) vertices;
array(float) texcoords;
array(float) normals;
} TextureGroup;
typedef struct {
char name[64];
Texture2D tex;
} CachedTexture;
// --- Game State ---
typedef struct {
Camera camera;
Model *world_models;
int world_model_count;
bool cursor_captured;
bool vsync;
} GameState;
extern GameState game;
// --- Prototypes ---
// Map
char map_peek(MapParser *p);
char map_get(MapParser *p);
void map_skip_whitespace(MapParser *p);
bool map_expect(MapParser *p, char expected);
void map_parse_token(MapParser *p, char *buffer, int size);
Vector3 map_parse_vector(MapParser *p);
Map ParseMap(const char *filename);
void FreeMap(Map map);
// Geometry
Plane PlaneFromPoints(Vector3 p1, Vector3 p2, Vector3 p3);
void PolyFree(Polygon p);
Polygon PolyClip(Polygon poly, Plane plane);
Polygon CreateLargeQuad(Plane plane);
Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane);
// Game
Texture2D GetTexture(const char *name);
void InitGame(void);
void UpdateGame(void);
void DrawGame(void);
bool LoadMap(const char *filename);
void UnloadMap(void);
#endif
|