Add minor improvements

This commit is contained in:
Miloslav Ciz 2025-06-03 19:48:52 +02:00
parent 7aca665d8e
commit ab8bcd4605
8 changed files with 53 additions and 44 deletions

View file

@ -25,6 +25,7 @@ fuck issue trackers :D
- valgrind, cppcheck, different compilers, optimization levels, ... - valgrind, cppcheck, different compilers, optimization levels, ...
- play replay from one platform on another - play replay from one platform on another
- profiling - profiling
- gigantic map that fails to fit in RAM
- replay stretching DID 1x - replay stretching DID 1x
- play all maps a lot - play all maps a lot
- correct saving of replays etc. - correct saving of replays etc.

View file

@ -116,16 +116,16 @@ int main(int argc, char *argv[])
if (!musicFile) if (!musicFile)
fputs("could not open music file",stderr); fputs("could not open music file",stderr);
LCR_log("initializing game"); puts("initializing game");
LCR_gameInit(argc,(const char **) argv); LCR_gameInit(argc,(const char **) argv);
LCR_log("initializing SFML"); puts("initializing SFML");
sfVideoMode mode = {LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y,32}; sfVideoMode mode = {LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y,32};
sfEvent event; sfEvent event;
clock = sfClock_create(); clock = sfClock_create();
sfClock_restart(clock); sfClock_restart(clock);
LCR_log("initializing audio"); puts("initializing audio");
for (int i = 0; i < AUDIO_BUFFER_SIZE; ++i) for (int i = 0; i < AUDIO_BUFFER_SIZE; ++i)
audioBuffer[i] = 0; audioBuffer[i] = 0;
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
sfRenderWindow_display(window); sfRenderWindow_display(window);
} }
LCR_log("ending"); puts("ending");
if (musicFile) if (musicFile)
fclose(musicFile); fclose(musicFile);

View file

@ -4,7 +4,8 @@
duplication of code. duplication of code.
*/ */
// TODO: quality presets? #include <stdint.h>
#include <stdio.h>
#if PRESET_QUALITY == 1 // ultra low #if PRESET_QUALITY == 1 // ultra low
#define LCR_SETTING_RESOLUTION_X 256 #define LCR_SETTING_RESOLUTION_X 256
@ -50,9 +51,6 @@
#define LCR_SETTING_FPS 45 #define LCR_SETTING_FPS 45
#endif #endif
#include <stdint.h>
#include <stdio.h>
#define DATA_FILE_NAME "data" #define DATA_FILE_NAME "data"
FILE *dataFile = 0; FILE *dataFile = 0;

View file

@ -11,8 +11,8 @@
#define LCR_FPS_GET_MS SDL_GetTicks() // uncomment for FPS measuring #define LCR_FPS_GET_MS SDL_GetTicks() // uncomment for FPS measuring
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
#define LCR_SETTING_RESOLUTION_X 640 #define LCR_SETTING_RESOLUTION_X 512
#define LCR_SETTING_RESOLUTION_Y 480 #define LCR_SETTING_RESOLUTION_Y 400
#define LCR_SETTING_MUSIC 0 #define LCR_SETTING_MUSIC 0
#define LCR_SETTING_CAR_SHADOW 0 #define LCR_SETTING_CAR_SHADOW 0
#define LCR_SETTING_TEXTURE_SUBSAMPLE 4 #define LCR_SETTING_TEXTURE_SUBSAMPLE 4
@ -173,13 +173,13 @@ int main(int argc, char *argv[])
fputs("could not open music file",stderr); fputs("could not open music file",stderr);
#endif #endif
LCR_log("initializing game"); puts("initializing game");
LCR_gameInit(argc,(const char **) argv); LCR_gameInit(argc,(const char **) argv);
LCR_log("initializing SDL"); puts("initializing SDL");
SDL_Init(SDL_INIT_AUDIO); SDL_Init(SDL_INIT_AUDIO);
LCR_log("initializing audio"); puts("initializing audio");
SDL_AudioSpec audioSpec; SDL_AudioSpec audioSpec;
SDL_memset(&audioSpec,0,sizeof(audioSpec)); SDL_memset(&audioSpec,0,sizeof(audioSpec));
audioSpec.callback = audioFillCallback; audioSpec.callback = audioFillCallback;
@ -243,7 +243,7 @@ int main(int argc, char *argv[])
SDL_PumpEvents(); SDL_PumpEvents();
keyboardState = SDL_GetKeyboardState(NULL); keyboardState = SDL_GetKeyboardState(NULL);
LCR_log("starting game loop"); puts("starting game loop");
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
emscripten_set_main_loop(mainLoopIteration,0,1); emscripten_set_main_loop(mainLoopIteration,0,1);
@ -252,7 +252,7 @@ int main(int argc, char *argv[])
mainLoopIteration(); mainLoopIteration();
#endif #endif
LCR_log("ending"); puts("ending");
if (musicFile) if (musicFile)
fclose(musicFile); fclose(musicFile);

View file

@ -67,6 +67,8 @@ int main(int argc, char **argv)
default: break; default: break;
} }
puts("initializing game");
LCR_gameInit(argc,(const char **) argv); LCR_gameInit(argc,(const char **) argv);
Display *display = XOpenDisplay(0); Display *display = XOpenDisplay(0);
@ -103,6 +105,8 @@ int main(int argc, char **argv)
/*DefaultDepth(display,screen)*/24,ZPixmap,0,framebuffer, /*DefaultDepth(display,screen)*/24,ZPixmap,0,framebuffer,
LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y,8,0); LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y,8,0);
puts("starting");
while (running) // main loop while (running) // main loop
{ {
XEvent event; XEvent event;
@ -143,6 +147,8 @@ int main(int argc, char **argv)
} }
} }
puts("ending");
XDestroyImage(image); XDestroyImage(image);
XCloseDisplay(display); XCloseDisplay(display);
closeDataFile(); closeDataFile();

5
game.h
View file

@ -1224,7 +1224,7 @@ void LCR_gameTimeToStr(uint32_t timeMS, char *str)
void LCR_gameDrawPopupMessage(void) void LCR_gameDrawPopupMessage(void)
{ {
#define _TEXT_SIZE 1 + 4 * (LCR_EFFECTIVE_RESOLUTION_Y > 96) #define _TEXT_SIZE 1 + 4 * (LCR_EFFECTIVE_RESOLUTION_Y > 96)
#define _OFFSET_V (LCR_EFFECTIVE_RESOLUTION_Y / 8) #define _OFFSET_V (LCR_EFFECTIVE_RESOLUTION_Y / 16)
int textH = LCR_rendererComputeTextHeight(_TEXT_SIZE); int textH = LCR_rendererComputeTextHeight(_TEXT_SIZE);
int textW = LCR_rendererComputeTextWidth(LCR_game.popupStr,_TEXT_SIZE); int textW = LCR_rendererComputeTextWidth(LCR_game.popupStr,_TEXT_SIZE);
@ -1514,7 +1514,8 @@ void LCR_gameHandleInput(void)
} }
else if (LCR_game.keyStates[LCR_KEY_B] == 1 && LCR_currentMap.blockCount) else if (LCR_game.keyStates[LCR_KEY_B] == 1 && LCR_currentMap.blockCount)
{ {
LCR_LOG1("menu quit"); LCR_LOG1("menu closed");
LCR_rendererLoadMapChunks();
LCR_gameSetState(LCR_game.statePrev); LCR_gameSetState(LCR_game.statePrev);
} }
else if (LCR_game.keyStates[LCR_KEY_A] == 1) else if (LCR_game.keyStates[LCR_KEY_A] == 1)

View file

@ -9,37 +9,40 @@ WORK IN PROGRESS
Licar is a relatively simple 3D stunt racing video game inspired by other Licar is a relatively simple 3D stunt racing video game inspired by other
popular games of the genre, such as Trackmania and Stunts. Unlike mainstream popular games of the genre, such as Trackmania and Stunts. Unlike mainstream
video games (even idie ones), Licar is completely libre, i.e. free as in freedom video games (even indie ones), Licar is completely libre, i.e. free as in
(meaning its source code and art assets are available for any use whatsoever), freedom (meaning its source code and art assets are available for any use
gratis (free of cost) and its focus lies in being well programmed by adhering to whatsoever), gratis (free of cost) and its focus lies in being well programmed
minimalism and rejecting harmful "modern" programming practices. The game aims by adhering to minimalism and rejecting harmful "modern" programming practices.
to seflessly bring joy and entertainment to all the people that might enjoy it, The game aims to seflessly bring joy and entertainment to all the people that
even those who aren't able or willing to pay and/or watch ads, those owning very might enjoy it, even those who aren't able or willing to pay and/or watch ads,
old and weak computers and so on. It was made in whole by a single man as a those owning very old and weak computers and so on. It was made in whole by a
completely non-commercial program, the development was driven purely by love of single man as a completely non-commercial program, the development was driven
the craft and other living beings to whom it might serve. Licar is also more purely by love of the craft and other living beings whom it might serve. Licar
than a game, for example it may serve educational purposes or become a basis for is also more than a game, for example it may serve educational purposes or
new projects. become a basis for new projects.
The game runs on many platforms and comes in different versions depending on The game runs on many platforms and comes in different flavors depending on
what the platforms allow. Some versions may have more features or visual what the platform allows. Some versions may have more features or visual
"richness" than others. If anything mentioned in this manual is missing in your "richness" than others. If anything mentioned in this manual is missing in your
game, it's probably because of limitations of your platform. On PCs and laptops, game, it's probably because of limitations of your platform. On PCs and laptops
however, everything should be supported. running the SDL version, however, everything should be supported.
~~~~~ RUNNING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ RUNNING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are compiled versions of Licar for many different platforms. If yours is There are compiled versions of Licar for many different platforms. If yours is
among them, running the game should be as simple as running any other program. among them, running the game should be as simple as running any other program.
Running the game from command line will provide logs that may be useful for
troubleshooting.
If there isn't a version for your system or for some other reason you can't If there isn't a version for your system or for whatever other reason you can't
run the game, you may try to compile the game yourself from the source code. run the precompiled game, you may try to compile the project yourself from the
This is very easy (unlike with most "modern" software), it usually involves source code. This is very simple (unlike with most "modern" software), it
typing a command in command line. For more detail check out the README. usually only involves typing a handful of command in the command line, and the
compilation should only take seconds. For more detail check out the README.
Note that it's also possible to play the game in a web browser or through some Note that it's also possible to play the game in a web browser or through some
kind of compatibility layer or emulator if there is no native executable for kind of compatibility layer (Wine, ...) or emulator if there is no native
your system. executable for your system.
If you know what command line arguments are, you may also check them out by 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 running the game with -h argument. This will allow you to for example start the

View file

@ -2048,7 +2048,7 @@ int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 12;
LCR_rendererComputeTextHeight(_FONT_SIZE) + 3 * LCR_FONT_PIXEL_SIZE; LCR_rendererComputeTextHeight(_FONT_SIZE) + 3 * LCR_FONT_PIXEL_SIZE;
++y) ++y)
#if LCR_EFFECTIVE_RESOLUTION_X > 500 #if LCR_EFFECTIVE_RESOLUTION_X > 500
for (int x = 20; x < LCR_EFFECTIVE_RESOLUTION_X - 20; ++x) for (int x = 40; x < LCR_EFFECTIVE_RESOLUTION_X - 40; ++x)
#else #else
for (int x = 2; x < LCR_EFFECTIVE_RESOLUTION_X - 2; ++x) for (int x = 2; x < LCR_EFFECTIVE_RESOLUTION_X - 2; ++x)
#endif #endif
@ -2073,7 +2073,7 @@ int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 12;
#if (!LCR_SETTING_POTATO_GRAPHICS) && (!LCR_ANT_RESOLUTION) #if (!LCR_SETTING_POTATO_GRAPHICS) && (!LCR_ANT_RESOLUTION)
LCR_rendererBlitImage(21,(LCR_EFFECTIVE_RESOLUTION_X - LCR_rendererBlitImage(21,(LCR_EFFECTIVE_RESOLUTION_X -
LCR_IMAGE_SIZE * (stripHeight / LCR_IMAGE_SIZE)) / 2,0, LCR_IMAGE_SIZE * (stripHeight / LCR_IMAGE_SIZE)) / 2,8,
stripHeight / LCR_IMAGE_SIZE,LCR_CONVERT_COLOR(0xffff)); stripHeight / LCR_IMAGE_SIZE,LCR_CONVERT_COLOR(0xffff));
#endif #endif