From fb96ec752215da56407c2266ab9d1eedf670e0d1 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Fri, 1 May 2026 03:53:58 +0200 Subject: Custom --width and --height cli argument --- main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 1ca42bd..cc96b3b 100644 --- a/main.c +++ b/main.c @@ -11,16 +11,20 @@ int main(int argc, char *argv[]) { 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 @@ int main(int argc, char *argv[]) { case 'f': target_fps = atoi(optarg); break; + case 'w': + width = atoi(optarg); + break; + case 'h': + height = atoi(optarg); + break; } } @@ -38,13 +48,15 @@ int main(int argc, char *argv[]) { 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) { -- cgit v1.2.3