aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-04-30 18:14:44 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-04-30 18:14:44 +0200
commit071162febcf763b153fe44ca8be5ed94551f3738 (patch)
tree2baabe921259f9260497e2903e1ab55843a76ad0
parent80c8c3997d6f9e6ce8a710c5702c10b6aec0aa78 (diff)
downloadstalag-071162febcf763b153fe44ca8be5ed94551f3738.tar.gz
Trenchbroom setup
-rw-r--r--README.md3
-rw-r--r--all.h2
-rw-r--r--game.c4
-rw-r--r--main.c2
-rw-r--r--maps/demo3.map33
-rw-r--r--trenchbroom/stalag/Entities.fgd7
6 files changed, 40 insertions, 11 deletions
diff --git a/README.md b/README.md
index f0e2c51..802e567 100644
--- a/README.md
+++ b/README.md
@@ -8,3 +8,6 @@ ln -s ~/Projects/stalag/trenchbroom/stalag/ ~/.TrenchBroom/games/
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
index ac97717..048750a 100644
--- a/all.h
+++ b/all.h
@@ -124,7 +124,7 @@ Vector2 GetUV(Vector3 p, MapPlane *mp, Plane plane);
124 124
125// Game 125// Game
126Texture2D GetTexture(const char *name); 126Texture2D GetTexture(const char *name);
127void InitGame(void); 127void InitGame(const char *map_path);
128void UpdateGame(void); 128void UpdateGame(void);
129void DrawGame(void); 129void DrawGame(void);
130bool LoadMap(const char *filename); 130bool LoadMap(const char *filename);
diff --git a/game.c b/game.c
index 168cae4..87fea13 100644
--- a/game.c
+++ b/game.c
@@ -223,7 +223,7 @@ bool LoadMap(const char *filename) {
223 return true; 223 return true;
224} 224}
225 225
226void InitGame(void) { 226void 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,7 +238,7 @@ void InitGame(void) {
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
index 481f5f3..e89aa1a 100644
--- a/main.c
+++ b/main.c
@@ -14,7 +14,7 @@ int main(void) {
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
index ab0e59d..bdd84f5 100644
--- a/maps/demo3.map
+++ b/maps/demo3.map
@@ -5,11 +5,32 @@
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} 14}
15} 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"
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"
36}
diff --git a/trenchbroom/stalag/Entities.fgd b/trenchbroom/stalag/Entities.fgd
index b6496a5..abf5256 100644
--- a/trenchbroom/stalag/Entities.fgd
+++ b/trenchbroom/stalag/Entities.fgd
@@ -21,4 +21,9 @@
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] \ No newline at end of file 24]
25
26@PointClass base(Targetname) = my_entity : "My Entity"
27[
28 speed(integer) : "Speed" : 100
29]