Add CLI arguments

This commit is contained in:
Miloslav Ciz 2025-03-05 17:10:01 +01:00
parent 5c8e4c4c2b
commit ffbc647024
5 changed files with 70 additions and 3 deletions

View file

@ -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

View file

@ -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 =

View file

@ -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)

3
game.h
View file

@ -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.
*/
/**

View file

@ -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 :)