From 428b68f791edcb89c811c9aca5dedbf7ec5d1335 Mon Sep 17 00:00:00 2001 From: Emil Williams Date: Tue, 17 Feb 2026 06:47:32 +0000 Subject: revised tiles, powerups, timer + basic gameplay --- source/main.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'source/main.c') diff --git a/source/main.c b/source/main.c index 70ab419..bc55b2d 100644 --- a/source/main.c +++ b/source/main.c @@ -1,10 +1,66 @@ #include "all.h" +#include + +#define arg if (++arguments, !--count) { goto help; } else +config_t Arguments(int count, char ** arguments) { + config_t config = {0}; + while (++arguments, --count > 0) { + while (**arguments == '-') { ++*arguments; } + struct options * option = options_lookup(*arguments,strlen(*arguments)); + if (!option) { + printf("Unknown option '%s', try 'help'\n", *arguments); + goto abort; + } + switch (option->number) { + case OPTION_HELP: { + help: + printf("help/h/? -- -- This.\n" + "resolution -- -- The on-display resolution squared\n" + "fps -- -- Framerate\n" + "ups -- -- Updates\n" + "font -- -- Glorious Font\n" + "spritesheet -- -- The spritesheet for displaying all of reality\n" + "spritesheet_scale -- -- The square scale of the above\n" + "players -- -- N players\n" + "map/map_size -- -- the in-game map size\n" + ); + exit(0); } + case OPTION_RESOLUTION: { + arg { config.resolution_x = atoi(*arguments); } + break; } + case OPTION_FPS: { + arg { config.fps = atoi(*arguments); } + break; } + case OPTION_UPS: { + arg { config.ups = atoi(*arguments); } + break; } + case OPTION_PLAYER_COUNT: { + arg { config.player_count = atoi(*arguments); } + break; } + case OPTION_MAP_SIZE: { + arg { config.map_x = atoi(*arguments); } + arg { config.map_y = atoi(*arguments); } + break; } + case OPTION_SPRITESHEET: { + arg { strlcpy(config.spritesheet, *arguments, CONFIG_STRING_LIMIT); } + break; } + case OPTION_SPRITESHEET_SCALE: { + arg { config.spritesheet_scale = atoi(*arguments); } + break; } + case OPTION_FONT: { + arg { strlcpy(config.font, *arguments, CONFIG_STRING_LIMIT); } + break; } + } + } + return config; +abort: + exit(1); +} int Main(int count, char ** arguments) { - (void)count; char * window_name = arguments[0]; - config_t config = (config_t){0}; + config_t config = Arguments(count, arguments); char * p = strchr(window_name, '/'); strlcpy(config.window_name, p ? p+1 : window_name, CONFIG_STRING_LIMIT); srand(time(NULL)); -- cgit v1.2.3