From c57ede96c977a153bfadda311dca74939697cf34 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Tue, 28 Jan 2025 00:10:47 +0100 Subject: [PATCH] Start arguments --- README.md | 8 +++++--- frontend_sdl.c | 2 +- game.h | 31 +++++++++++++++++++++++++------ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index adfd7af..eb84627 100644 --- a/README.md +++ b/README.md @@ -29,16 +29,18 @@ Some of the **gameplay features** include: ## Why This Game Is Special - **Everything is written in KISS/suckless C99 from scratch**. The whole project, including the physics engine, rendering engine, game logic and assets embedded in source code have TODO lines of code in total. -- **Everything is created 100% from scratch** by the author, including code (of the game, physics engine, 3D rendering engine, frontends), textures (created from own photos), 3D models, sound effects, music (created using custom sound font made from own recorded samples), font, accompanying materials etcetc. This ensures absolute freedom, there is no shadow of a doubt there is indeed is no 3rd party copyright. Everything was also **created exclusively with free software**. +- **Everything is created 100% from scratch** by the author, including code (of the game, physics engine, 3D rendering engine, frontends), textures (created from own photos), 3D models, map, sound effects, music (created using custom sound font made from own recorded samples), font, accompanying materials etcetc. This ensures absolute freedom, there is no shadow of a doubt there is indeed is no 3rd party copyright. Everything was also **created exclusively with free software**. - It has **custom KISS 3D physics engine** (tinyphysicsengine) written from scratch, implemented in a single header file, using **no GPU or floating point**. - It has **custom KISS 3D software rendering engine** (small3dlib) written from scratch, implemented in a single header file, using **no GPU or floating point**. - The whole game **doesn't use floating point at all**, everything is done with fixed point. -- It **doesn't have any dependency libraries, not even the C standard library**, everything is written from scratch for **maximum portability**. Libraries such as SDL are used for frontends, but they are never an inherent part of the project, they can be basically drop in replaced with a similar library. +- It **doesn't have any dependency libraries, not even the C standard library** (except for using types from *stdint.h*, which can be trivially replaced with a few *defines*), everything is written from scratch for **maximum portability**. Libraries such as SDL are used for frontends, but they are never an inherent dependency and can be basically drop-in replaced with a similar library that's only required to be able to draw pixels and read keyboard. Almost everything can be turned off, the game can even **run without a file system** as the essential assets are embedded right in the source code -- files are only needed for optional extended functionality like saving replays, adding extra maps etc. Settings are part of the source code too, there are **no config files**. - **No build system** is used, everything is in a **single compilation unit**, to build the game only a single compiler invocation is needed. This removes another bloat and dependency. +- The compiled game INCLUDING ASSETS is **extremely small**: TODO. - It is **extremely portable and future proof** thanks to having no dependencies besides C99 compiler. So far it was ported to: - TODO - It is **extremely moddable and hackable**, the code is relatively simple and well commented, written to encourage hacking. There are no obstacles such as DRM, anti-cheating, obfuscation etc. Cheating and hacking is allowed, do literally what you want. -- **No codes of censorship, flags or similar political bullshit**. This is just a game. +- **No codes of censorship, flags, furry mascots or similar political bullshit**. This is just a game. +- **No "modern" bullshit such as OOP, meme design patterns, scripting and similar nonsense**. - It is **absolutely and completely public domain free software with ZERO conditions on use** under CC0, it is legally more free that most "FOSS" software, there is no copyleft or credit requirement, you can do ABSOLUTELY anything you want with the project. This is a **selfless project aiming for no benefit of the creator** (include any non-finacial benefit as well), this is made purely to bring more good to the world without gaining any advantage for self. ## Manifesto diff --git a/frontend_sdl.c b/frontend_sdl.c index 96c1af5..6864652 100644 --- a/frontend_sdl.c +++ b/frontend_sdl.c @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) LCR_log("couldn't open data file"); LCR_log("initializing game"); - LCR_gameInit(); + LCR_gameInit(argc,(const char **) argv); LCR_log("initializing SDL"); SDL_Init(SDL_INIT_AUDIO); diff --git a/game.h b/game.h index d53fa0b..39b98b9 100644 --- a/game.h +++ b/game.h @@ -120,9 +120,10 @@ char LCR_getNextDataFileChar(void); void LCR_appendDataStr(const char *str); /** - Call this function in your frontend at the start of the program. + Call this function in your frontend at the start of the program. Pass program + arguments if there are any. */ -void LCR_gameInit(void); +void LCR_gameInit(int argc, const char **argv); /** Call this function in your frontend right before program end. @@ -736,7 +737,7 @@ void LCR_gameLoadMainMenuItems(void) LCR_game.menu.itemCount = 4; } -void LCR_gameInit(void) +void LCR_gameInit(int argc, const char **argv) { LCR_LOG0("initializing"); @@ -744,7 +745,6 @@ void LCR_gameInit(void) LCR_game.keyStates[i] = 0; LCR_rendererInit(); - LCR_racingInit(); LCR_audioInit(); @@ -762,10 +762,29 @@ void LCR_gameInit(void) LCR_game.nextRacingTickTime = 0; LCR_game.cameraMode = LCR_CAMERA_MODE_DRIVE; + LCR_LOG2("parsing arguments"); + + while (argc) // parse arguments + { + argc--; + + if (argv[argc][0] == '-') + switch (argv[argc][1]) + { + case 'c': LCR_game.cameraMode = (argv[argc][2] - '0') % 4; break; + case 'm': LCR_game.musicOn = argv[argc][2] != '0'; break; + case 's': LCR_audio.on = argv[argc][2] != '0'; break; + + // TODO + + default: + LCR_LOG2("unknown argument"); + break; + } + } + LCR_gameLoadMainMenuItems(); - LCR_gameSetState(LCR_GAME_STATE_MENU); - LCR_currentMap.blockCount = 0; // means no map loaded }