aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-05-01 03:53:58 +0200
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-05-01 03:53:58 +0200
commitfb96ec752215da56407c2266ab9d1eedf670e0d1 (patch)
tree9654257120ab890720946e5bc23bff9df0803348 /main.c
parent08eada80a4fd13028f2a19108788f76752cc459b (diff)
downloadstalag-fb96ec752215da56407c2266ab9d1eedf670e0d1.tar.gz
Custom --width and --height cli argument
Diffstat (limited to 'main.c')
-rw-r--r--main.c16
1 files changed, 14 insertions, 2 deletions
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[]) {
11 11
12 bool skip_title = false; 12 bool skip_title = false;
13 int target_fps = -1; 13 int target_fps = -1;
14 int width = WINDOW_WIDTH;
15 int height = WINDOW_HEIGHT;
14 16
15 static struct option long_options[] = { 17 static struct option long_options[] = {
16 {"map", required_argument, 0, 'm'}, 18 {"map", required_argument, 0, 'm'},
17 {"fps", required_argument, 0, 'f'}, 19 {"fps", required_argument, 0, 'f'},
20 {"width", required_argument, 0, 'w'},
21 {"height", required_argument, 0, 'h'},
18 {0, 0, 0, 0} 22 {0, 0, 0, 0}
19 }; 23 };
20 24
21 int opt; 25 int opt;
22 int option_index = 0; 26 int option_index = 0;
23 while ((opt = getopt_long_only(argc, argv, "m:f:", long_options, &option_index)) != -1) { 27 while ((opt = getopt_long_only(argc, argv, "m:f:w:h:", long_options, &option_index)) != -1) {
24 switch (opt) { 28 switch (opt) {
25 case 'm': 29 case 'm':
26 sb_free(&map_path); 30 sb_free(&map_path);
@@ -31,6 +35,12 @@ int main(int argc, char *argv[]) {
31 case 'f': 35 case 'f':
32 target_fps = atoi(optarg); 36 target_fps = atoi(optarg);
33 break; 37 break;
38 case 'w':
39 width = atoi(optarg);
40 break;
41 case 'h':
42 height = atoi(optarg);
43 break;
34 } 44 }
35 } 45 }
36 46
@@ -38,13 +48,15 @@ int main(int argc, char *argv[]) {
38 if (target_fps < 0) flags |= FLAG_VSYNC_HINT; 48 if (target_fps < 0) flags |= FLAG_VSYNC_HINT;
39 49
40 SetConfigFlags(flags); 50 SetConfigFlags(flags);
41 InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE); 51 InitWindow(width, height, WINDOW_TITLE);
42 52
43 int monitor = GetCurrentMonitor(); 53 int monitor = GetCurrentMonitor();
44 SetWindowPosition((GetMonitorWidth(monitor) - GetScreenWidth()) / 2, (GetMonitorHeight(monitor) - GetScreenHeight()) / 2); 54 SetWindowPosition((GetMonitorWidth(monitor) - GetScreenWidth()) / 2, (GetMonitorHeight(monitor) - GetScreenHeight()) / 2);
45 55
46 vfs_init(VFS_DATA_PAK); 56 vfs_init(VFS_DATA_PAK);
47 InitGame(); 57 InitGame();
58 game.screen_width = width;
59 game.screen_height = height;
48 SetMap(map_path.data); 60 SetMap(map_path.data);
49 61
50 if (target_fps >= 0) { 62 if (target_fps >= 0) {