diff --git a/all.h b/all.h index 8821f86b6e148b1a4784266395e76095427983e0..b0dde0c46612b16b68f9bce5aab210766bc7620d 100644 --- a/all.h +++ b/all.h @@ -131,6 +131,8 @@ Camera camera; bool cursor_captured; bool vsync; int target_fps; + int screen_width; + int screen_height; Font font_ui; PlayerState player; diff --git a/main.c b/main.c index 1ca42bd3ea2d25d5ed228c3255e71b93c07fe7d9..cc96b3b2fdc27b32f9541c5c04efc58e399f4e35 100644 --- a/main.c +++ b/main.c @@ -11,16 +11,20 @@ sb_append_cstr(&map_path, "maps/demo3.map"); bool skip_title = false; int target_fps = -1; + int width = WINDOW_WIDTH; + int height = WINDOW_HEIGHT; static struct option long_options[] = { {"map", required_argument, 0, 'm'}, {"fps", required_argument, 0, 'f'}, + {"width", required_argument, 0, 'w'}, + {"height", required_argument, 0, 'h'}, {0, 0, 0, 0} }; int opt; int option_index = 0; - while ((opt = getopt_long_only(argc, argv, "m:f:", long_options, &option_index)) != -1) { + while ((opt = getopt_long_only(argc, argv, "m:f:w:h:", long_options, &option_index)) != -1) { switch (opt) { case 'm': sb_free(&map_path); @@ -31,6 +35,12 @@ break; case 'f': target_fps = atoi(optarg); break; + case 'w': + width = atoi(optarg); + break; + case 'h': + height = atoi(optarg); + break; } } @@ -38,13 +48,15 @@ unsigned int flags = FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI; if (target_fps < 0) flags |= FLAG_VSYNC_HINT; SetConfigFlags(flags); - InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE); + InitWindow(width, height, WINDOW_TITLE); int monitor = GetCurrentMonitor(); SetWindowPosition((GetMonitorWidth(monitor) - GetScreenWidth()) / 2, (GetMonitorHeight(monitor) - GetScreenHeight()) / 2); vfs_init(VFS_DATA_PAK); InitGame(); + game.screen_width = width; + game.screen_height = height; SetMap(map_path.data); if (target_fps >= 0) { diff --git a/tbrun.sh b/tbrun.sh index bf810bcf7702c9d8aca7b4d402671ca101e6eccc..8a600b790f5bba8f75a28e3208567838c54f567e 100755 --- a/tbrun.sh +++ b/tbrun.sh @@ -20,6 +20,8 @@ echo "$SCRIPT_DIR" MAP="" FPS="" +WIDTH="" +HEIGHT="" while [ $# -gt 0 ]; do case "$1" in --map) @@ -36,6 +38,20 @@ ;; --fps=*) FPS="${1#--fps=}" ;; + --width) + shift + WIDTH="$1" + ;; + --width=*) + WIDTH="${1#--width=}" + ;; + --height) + shift + HEIGHT="$1" + ;; + --height=*) + HEIGHT="${1#--height=}" + ;; --) shift; break;; *) ;; esac @@ -43,4 +59,7 @@ shift done cd "$SCRIPT_DIR" -./bin/stalag --map "$MAP" --fps "$FPS" +./bin/stalag --map "$MAP" \ + ${FPS:+--fps "$FPS"} \ + ${WIDTH:+--width "$WIDTH"} \ + ${HEIGHT:+--height "$HEIGHT"} diff --git a/trenchbroom/stalag/GameEngineProfiles.cfg b/trenchbroom/stalag/GameEngineProfiles.cfg index fb04830c63853c7ecc0e14e091068884f8563690..81eda2f11fde69300f1c2a14b8f988031989c919 100644 --- a/trenchbroom/stalag/GameEngineProfiles.cfg +++ b/trenchbroom/stalag/GameEngineProfiles.cfg @@ -1,10 +1,10 @@ { - "profiles": [ - { - "name": "Stalag", - "parameters": "--fps 120 --map maps/${MAP_BASE_NAME}.map", - "path": "/home/m/Projects/stalag/tbrun.sh" - } - ], - "version": 1 + "profiles": [ + { + "name": "Stalag", + "parameters": "--fps 120 --width 1920 --height 1080 --map maps/${MAP_BASE_NAME}.map", + "path": "/home/m/Projects/stalag/tbrun.sh" + } + ], + "version": 1 }