Trenchbroom setup
| Author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-04-30 18:14:44 +0200 |
| Committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-04-30 18:14:44 +0200 |
| Commit | 071162febcf763b153fe44ca8be5ed94551f3738 (patch) |
|
-rw-r--r-- |
README.md | 3 | |
-rw-r--r-- |
all.h | 2 | |
-rw-r--r-- |
game.c | 4 | |
-rw-r--r-- |
main.c | 2 | |
-rw-r--r-- |
maps/demo3.map | 33 | |
-rw-r--r-- |
trenchbroom/stalag/Entities.fgd | 7 |
6 files changed, 40 insertions, 11 deletions
| diff --git a/README.md b/README.md | |||
| ... | |||
| 8 | - Open Trenchbroom and go to `View>Preferences` and check that `Game Path` |
8 | - Open Trenchbroom and go to `View>Preferences` and check that `Game Path` |
| 9 | points to project root. |
9 | points to project root. |
| 10 | 10 | ||
| 11 | ## Trenchbroom entities |
||
| 12 | |||
| 13 | - https://developer.valvesoftware.com/wiki/FGD |
||
| diff --git a/all.h b/all.h | |||
| ... | |||
| 124 | 124 | ||
| 125 | // Game |
125 | // Game |
| 126 | Texture2D GetTexture(const char *name); |
126 | Texture2D GetTexture(const char *name); |
| 127 | void InitGame(void); |
127 | void InitGame(const char *map_path); |
| 128 | void UpdateGame(void); |
128 | void UpdateGame(void); |
| 129 | void DrawGame(void); |
129 | void DrawGame(void); |
| 130 | bool LoadMap(const char *filename); |
130 | bool LoadMap(const char *filename); |
| ... | |||
| diff --git a/game.c b/game.c | |||
| ... | |||
| 223 | return true; |
223 | return true; |
| 224 | } |
224 | } |
| 225 | 225 | ||
| 226 | void InitGame(void) { |
226 | void InitGame(const char* map_path) { |
| 227 | array_init(texture_cache); |
227 | array_init(texture_cache); |
| 228 | game.world_models = NULL; |
228 | game.world_models = NULL; |
| 229 | game.world_model_count = 0; |
229 | game.world_model_count = 0; |
| ... | |||
| 238 | game.font_ui = GetFontDefault(); |
238 | game.font_ui = GetFontDefault(); |
| 239 | } |
239 | } |
| 240 | 240 | ||
| 241 | LoadMap("maps/demo1.map"); |
241 | LoadMap(map_path); |
| 242 | 242 | ||
| 243 | game.cursor_captured = false; |
243 | game.cursor_captured = false; |
| 244 | EnableCursor(); |
244 | EnableCursor(); |
| ... | |||
| diff --git a/main.c b/main.c | |||
| ... | |||
| 14 | SetTargetFPS(GetMonitorRefreshRate(monitor)); |
14 | SetTargetFPS(GetMonitorRefreshRate(monitor)); |
| 15 | 15 | ||
| 16 | vfs_init("data.pak"); |
16 | vfs_init("data.pak"); |
| 17 | InitGame(); |
17 | InitGame("maps/demo3.map"); |
| 18 | game.vsync = true; |
18 | game.vsync = true; |
| 19 | 19 | ||
| 20 | while (!WindowShouldClose()) { |
20 | while (!WindowShouldClose()) { |
| ... | |||
| diff --git a/maps/demo3.map b/maps/demo3.map | |||
| ... | |||
| 5 | "classname" "worldspawn" |
5 | "classname" "worldspawn" |
| 6 | // brush 0 |
6 | // brush 0 |
| 7 | { |
7 | { |
| 8 | ( -176 -64 -32 ) ( -176 -63 -32 ) ( -176 -64 -31 ) brushes/bricks_076c 0 -16 0 1 1 |
8 | ( -592 -16 -32 ) ( -592 -15 -32 ) ( -592 -16 -31 ) brushes/bricks_076c -48 -16 0 1 1 |
| 9 | ( -64 -432 -32 ) ( -64 -432 -31 ) ( -63 -432 -32 ) brushes/bricks_076c 0 -16 0 1 1 |
9 | ( -64 -384 -32 ) ( -64 -384 -31 ) ( -63 -384 -32 ) brushes/bricks_076c 0 -16 0 1 1 |
| 10 | ( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) brushes/bricks_076c 0 0 0 1 1 |
10 | ( -64 -16 -16 ) ( -63 -16 -16 ) ( -64 -15 -16 ) brushes/bricks_076c 0 48 0 1 1 |
| 11 | ( 64 64 0 ) ( 64 65 0 ) ( 65 64 0 ) brushes/bricks_076c 0 0 0 1 1 |
11 | ( 64 112 0 ) ( 64 113 0 ) ( 65 112 0 ) brushes/bricks_076c 0 48 0 1 1 |
| 12 | ( 64 64 0 ) ( 65 64 0 ) ( 64 64 1 ) brushes/bricks_076c 0 -16 0 1 1 |
12 | ( 64 336 0 ) ( 65 336 0 ) ( 64 336 1 ) brushes/bricks_076c 0 -16 0 1 1 |
| 13 | ( 64 64 0 ) ( 64 64 1 ) ( 64 65 0 ) brushes/bricks_076c 0 -16 0 1 1 |
13 | ( 560 112 0 ) ( 560 112 1 ) ( 560 113 0 ) brushes/bricks_076c -48 -16 0 1 1 |
| 14 | } |
||
| 15 | } |
||
| 16 | // entity 1 |
||
| 17 | { |
||
| 18 | "classname" "light" |
||
| 19 | "origin" "136 -280 184" |
||
| 20 | } |
||
| 21 | // entity 2 |
||
| 22 | { |
||
| 23 | "classname" "light" |
||
| 24 | "origin" "-200 24 184" |
||
| 14 | } |
25 | } |
| 26 | // entity 3 |
||
| 27 | { |
||
| 28 | "classname" "info_player_start" |
||
| 29 | "origin" "-128 -112 16" |
||
| 30 | } |
||
| 31 | // entity 4 |
||
| 32 | { |
||
| 33 | "classname" "my_entity" |
||
| 34 | "origin" "8 -72 8" |
||
| 35 | "speed" "100" |
||
| 15 | } |
36 | } |
| diff --git a/trenchbroom/stalag/Entities.fgd b/trenchbroom/stalag/Entities.fgd | |||
| ... | |||
| 21 | @PointClass base(Targetname, Origin) size(-8 -8 -8, 8 8 8) = light : "Light" |
21 | @PointClass base(Targetname, Origin) size(-8 -8 -8, 8 8 8) = light : "Light" |
| 22 | [ |
22 | [ |
| 23 | light(integer) : "Brightness" : 300 |
23 | light(integer) : "Brightness" : 300 |
| 24 | ] |
24 | ] |
| 25 | |||
| 26 | @PointClass base(Targetname) = my_entity : "My Entity" |
||
| 27 | [ |
||
| 28 | speed(integer) : "Speed" : 100 |
||
| 29 | ] |
||