-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathmap_parser.h
More file actions
55 lines (43 loc) · 1.49 KB
/
map_parser.h
File metadata and controls
55 lines (43 loc) · 1.49 KB
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
#pragma once
#include <stdbool.h>
#include <stdint.h>
/* Maximum map dimensions for .ray files */
#define MAP_MAX_X 64
#define MAP_MAX_Y 64
/* Maximum line length in .ray files */
#define MAP_LINE_MAX 256
/* Maximum file size for .ray files (64 KB) */
#define MAP_FILE_MAX (64 * 1024)
/* Maximum texture path length */
#define MAP_PATH_MAX 128
typedef struct {
/* Map grid: 0 = floor, 1 = wall. Row-major: grid[y * width + x] */
uint8_t grid[MAP_MAX_Y * MAP_MAX_X];
uint8_t width;
uint8_t height;
/* Player spawn in 8.8 fixed-point (center of spawn tile + 128) */
uint16_t spawnX;
uint16_t spawnY;
int16_t spawnA; /* 0-1023 angle system */
/* Texture paths (parsed but not loaded until NSWE textures are implemented)
*/
char texN[MAP_PATH_MAX];
char texS[MAP_PATH_MAX];
char texW[MAP_PATH_MAX];
char texE[MAP_PATH_MAX];
/* Floor and ceiling colors (RGB, 0-255 each) */
uint8_t floorR, floorG, floorB;
uint8_t ceilR, ceilG, ceilB;
} MapConfig;
/* Parse a .ray map file. Returns true on success, false on error.
* Error messages are printed to stderr.
*/
bool MapConfigLoad(const char *filename, MapConfig *config);
/* Install a parsed map as the active runtime map.
* After this call, MapIsWall() uses the runtime grid instead of compiled-in
* data.
*/
void MapRuntimeInstall(const MapConfig *config);
/* Runtime map dimensions. Only valid when g_mapRuntimeActive is true. */
uint8_t MapRuntimeWidth(void);
uint8_t MapRuntimeHeight(void);