aboutsummaryrefslogtreecommitdiff
path: root/all.h
diff options
context:
space:
mode:
Diffstat (limited to 'all.h')
-rw-r--r--all.h161
1 files changed, 91 insertions, 70 deletions
diff --git a/all.h b/all.h
index ac97717..26ccffb 100644
--- a/all.h
+++ b/all.h
@@ -15,122 +15,143 @@
15#include <stdbool.h> 15#include <stdbool.h>
16#include <stddef.h> 16#include <stddef.h>
17 17
18// --- Map Structures --- 18#ifndef PLAYER_FOV
19#define PLAYER_FOV 90.0f
20#endif
19 21
20typedef struct { 22typedef struct {
21 Vector3 p[3]; 23 Vector3 p[3];
22 char texture[64]; 24 char texture[64];
23 float shift[2]; 25 float shift[2];
24 float rotate; 26 float rotate;
25 float scale[2]; 27 float scale[2];
26} MapPlane; 28} MapPlane;
27 29
28typedef struct { 30typedef struct {
29 MapPlane *planes; 31 MapPlane *planes;
30 int plane_count; 32 int plane_count;
31} MapBrush; 33} MapBrush;
32 34
33typedef struct { 35typedef struct {
34 char key[64]; 36 char key[64];
35 char value[256]; 37 char value[256];
36} MapProperty; 38} MapProperty;
37 39
38typedef struct { 40typedef struct {
39 MapProperty *properties; 41 MapProperty *properties;
40 int property_count; 42 int property_count;
41 MapBrush *brushes; 43 MapBrush *brushes;
42 int brush_count; 44 int brush_count;
43} MapEntity; 45} MapEntity;
44 46
45typedef struct { 47typedef struct {
46 MapEntity *entities; 48 MapEntity *entities;
47 int entity_count; 49 int entity_count;
48} Map; 50} Map;
49 51
50typedef struct { 52typedef struct {
51 const char *data; 53 const char *data;
52 size_t length; 54 size_t length;
53 size_t pos; 55 size_t pos;
54} MapParser; 56} MapParser;
55 57
56typedef struct { 58typedef struct {
57 Vector3 normal; 59 Vector3 normal;
58 float dist; 60 float dist;
59} Plane; 61} Plane;
60 62
61typedef struct { 63typedef struct {
62 Vector3 *verts; 64 Vector3 *verts;
63 int count; 65 int count;
64} Polygon; 66} Polygon;
65 67
66typedef struct { 68typedef struct {
67 char texture[64]; 69 char texture[64];
68 array(float) vertices; 70 array(float) vertices;
69 array(float) texcoords; 71 array(float) texcoords;
70 array(float) normals; 72 array(float) normals;
71} TextureGroup; 73} TextureGroup;
72 74
73typedef struct { 75typedef struct {
74 char name[64]; 76 char name[64];
75 Texture2D tex; 77 Texture2D tex;
76} CachedTexture; 78} CachedTexture;
77 79
78// --- Game State --- 80// Asset Module
81Texture2D GetTexture(const char *name);
82void UnloadAssets(void);
83Font LoadFontVFS(const char *path, int fontSize);
84
85// Map Module
86typedef struct {
87 Model *models;
88 int count;
89} MapState;
79 90
91bool LoadMap(const char *filename);
92void UnloadMap(void);
93bool CheckMapCollision(Vector3 start, Vector3 end, RayCollision *outCollision);
94Map ParseMap(const char *filename);
95void FreeMap(Map map);
96
97// Menu Module
98void UpdateMenu(void);
99void DrawMenu(void);
100
101// Player Module
80typedef enum { 102typedef enum {
81 MOVE_NORMAL, 103 MOVE_NORMAL,
82 MOVE_FLY 104 MOVE_FLY
83} MovementMode; 105} MovementMode;
84 106
85typedef struct { 107typedef struct {
86 Camera camera; 108 MovementMode move_mode;
87 Model *world_models; 109 Vector3 pos;
88 int world_model_count; 110 Vector3 velocity;
89 bool cursor_captured; 111 bool is_grounded;
90 bool vsync; 112 float yaw;
91 Font font_ui; 113 float pitch;
92 114 float lean_amount;
93 MovementMode move_mode; 115 float crouch_amount;
94 Vector3 pos; 116 float horizontal_speed;
95 Vector3 velocity; 117} PlayerState;
96 bool is_grounded; 118
97 float yaw; 119void UpdatePlayer(void);
98 float pitch; 120
99 float lean_amount; 121// Game State Module
100 float crouch_amount; 122typedef enum {
101 float horizontal_speed; 123 STATE_MENU,
124 STATE_PLAYING
125} GameStateMode;
126
127typedef struct {
128 GameStateMode mode;
129 char map_path[256];
130 Camera camera;
131 bool cursor_captured;
132 bool vsync;
133 Font font_ui;
134
135 PlayerState player;
136 MapState map;
102} GameState; 137} GameState;
103 138
104extern GameState game; 139extern GameState game;
105 140
106// --- Prototypes --- 141void InitGame(void);
107 142void SetMap(const char *path);
108// Map 143void UpdateGame(void);
109char map_peek(MapParser *p); 144void DrawGame(void);
110char map_get(MapParser *p);
111void map_skip_whitespace(MapParser *p);
112bool map_expect(MapParser *p, char expected);
113void map_parse_token(MapParser *p, char *buffer, int size);
114Vector3 map_parse_vector(MapParser *p);
115Map ParseMap(const char *filename);
116void FreeMap(Map map);
117 145
118// Geometry 146// Geometry Helpers
119Plane PlaneFromPoints(Vector3 p1, Vector3 p2, Vector3 p3); 147Plane PlaneFromPoints(Vector3 p1, Vector3 p2, Vector3 p3);
120void PolyFree(Polygon p); 148void PolyFree(Polygon p);
121Polygon PolyClip(Polygon poly, Plane plane); 149Polygon PolyClip(Polygon poly, Plane plane);
122Polygon CreateLargeQuad(Plane plane); 150Polygon CreateLargeQuad(Plane plane);
123Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane); 151Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane);
124 152
125// Game 153// Interface
126Texture2D GetTexture(const char *name); 154void DrawCrosshair(void);
127void InitGame(void); 155void DrawDebugInfo(void);
128void UpdateGame(void);
129void DrawGame(void);
130bool LoadMap(const char *filename);
131void UnloadMap(void);
132
133// Player
134void UpdatePlayer(void);
135 156
136#endif 157#endif