From ffbc647024ef13dea617d15f7c24807cb3d0cc9b Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Wed, 5 Mar 2025 17:10:01 +0100 Subject: [PATCH] Add CLI arguments --- TODO.txt | 1 + assets.h | 10 ++++++++++ frontend_sdl.c | 24 ++++++++++++++++++++++++ game.h | 3 +++ media/manual.txt | 35 ++++++++++++++++++++++++++++++++--- 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/TODO.txt b/TODO.txt index 80a365b..b1ffc33 100644 --- a/TODO.txt +++ b/TODO.txt @@ -24,6 +24,7 @@ - traveling salesman kind of maze, with fans n shit - city map? - some kinda buggy bumpy downhill + - map where car starts upside down - dirt map - ice map - boss map diff --git a/assets.h b/assets.h index 5968f3f..2f4fb76 100644 --- a/assets.h +++ b/assets.h @@ -48,6 +48,16 @@ static const char *LCR_texts[] = "saved" }; +#define LCR_VERSION "0.1d" + +/// String that can be used by frontends to offer help about CLI arguments. +#define LCR_ARG_HELP_STR \ + " -cN set camera mode to N\n" \ + " -s0 turn sound off\n" \ + " -m0 turn music off\n" \ + " -M load the last map in the data file\n" \ + " -R load the last replay in the data file\n" + // TODO: define string for CLI arguments for frontends? static const char *LCR_internalDataFile = diff --git a/frontend_sdl.c b/frontend_sdl.c index 41ff148..c6c9a7a 100644 --- a/frontend_sdl.c +++ b/frontend_sdl.c @@ -115,10 +115,34 @@ void LCR_log(const char *str) printf("LOG: %s\n",str); } +void printHelp(void) +{ + printf( + "Licar, 3D racing game, version " LCR_VERSION ", arguments:\n" + " -h print help and quit\n" + LCR_ARG_HELP_STR); +} + int main(int argc, char *argv[]) { uint8_t running = 1; + for (int i = 0; i < argc; ++i) + if (argv[i][0] == '-') + switch (argv[i][1]) + { + case 'h': + if (argv[i][2] == 0) + { + printHelp(); + return 0; + } + + break; + + default: break; + } + dataFile = fopen(DATA_FILE_NAME,"r"); if (!dataFile) diff --git a/game.h b/game.h index 6c3de70..13cd220 100644 --- a/game.h +++ b/game.h @@ -73,6 +73,9 @@ music is currently enabled (if not, stop playing it). If you don't want to support music, set LCR_SETTING_MUSIC to 0 in your frontend code (before including this module) so that the game knows music is disabled. + - LCR_ARG_HELP_STR is a string containing help for CLI arguments that can be + passed to LCR_gameInit. You can use this in your CLI help. You can also use + other strings such as LCR_VERSION. */ /** diff --git a/media/manual.txt b/media/manual.txt index b97c35a..148bc8e 100644 --- a/media/manual.txt +++ b/media/manual.txt @@ -2,7 +2,7 @@ WORK IN PROGRESS -._.-'"'-._.-'"'- LICAR MANUAL -'"'-._.-'"'-._.- -by drummyfish, released under CC0 1.0, punlic domain +by drummyfish, released under CC0 1.0, public domain ~~~ GENERAL ~~~ @@ -40,7 +40,7 @@ If you know what command line arguments are, you may also check them out by running the game with -h argument. This will allow you to for example start the game and immediately load a map, which is handy when creating new maps. -~~~ OBJECTIVES ~~~ +~~~ GAMEPLAY ~~~ In Licar, unlike in most other racing games, you only race against time, i.e. you are alone on the track. There is an option to race against a replay ghost, @@ -55,6 +55,11 @@ to beat in the bottom left of the screen. If you beat the time, you have achieved the goal, your replay is automatically saved and your new time becomes the next target time. +On the map there can be several different kinds of surfaces with different +physics properties: concrete, grass, dirt and ice. Furthermore there are two +special kind of sufaces: an accelerator (a bright yellow/orange one), which +boosts the car's speed, and a fan, which propels the car upwards. + Your run can be restarted at any time. Typically you will need hundreds of attempts to achieve a good time on a map. @@ -124,7 +129,21 @@ where exactly time losses against the opponent occur. ~~~ MAKING CUSTOM MAPS ~~~ -Maps are stored in the data file. +Maps are stored in the data file. For its simplicity the original game doesn't +come with a user-friendly map editor, the maps are hand-written directly in the +text format that's stored in the data file, however there is a helper file for +Blender that facilitates this process. + +The map is a 64x64x64 grid, with each cell one unit in width, one unit in depth +and half a unit in height. In the cell blocks can be placed. There are several +types of blocks such as ramps, walls, corners etc. Each block can be rotated +and/or flipped. Additionally each block also has a material (concrete, grass, +...). The finish, checkpoints and car start position can also be seen as block. + +The format of the map data string is described in the map.h file, refer to it +for further detail. In short: TODO + + Under the asset directory there is a helper file for Blender (a FOSS 3D editor) with which a map layout can be comfortably created. But Blender is not required @@ -143,3 +162,13 @@ The "workflow" for making maps is roughly the following: 1. or 2. ~~~ FAQ ~~~ + +Q: Why is the physics so buggy? + +A: You are right in the observation that Licar physics is not perfect. This is +firstly because of the game's aim for simplicity (e.g. avoiding use of floating +point) combined with the fact that even without such constraints it's one of the +most difficult tasks to create a flawless physics engine. We apologize for any +frustration but unless you want to fix this yourself, you'll have to just accept +it, the game is meant to be a simple entertainment. In other words this is a +feature :)