From ab8bcd46057507b300f752d9787a292b98a7c415 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Tue, 3 Jun 2025 19:48:52 +0200 Subject: [PATCH] Add minor improvements --- TODO.txt | 1 + frontend_csfml.c | 8 ++++---- frontend_helper.h | 14 ++++++-------- frontend_sdl.c | 14 +++++++------- frontend_x11.c | 6 ++++++ game.h | 5 +++-- media/manual.txt | 45 ++++++++++++++++++++++++--------------------- renderer.h | 4 ++-- 8 files changed, 53 insertions(+), 44 deletions(-) diff --git a/TODO.txt b/TODO.txt index 0073aab..549b86f 100644 --- a/TODO.txt +++ b/TODO.txt @@ -25,6 +25,7 @@ fuck issue trackers :D - valgrind, cppcheck, different compilers, optimization levels, ... - play replay from one platform on another - profiling + - gigantic map that fails to fit in RAM - replay stretching DID 1x - play all maps a lot - correct saving of replays etc. diff --git a/frontend_csfml.c b/frontend_csfml.c index fbc44de..d9554d4 100644 --- a/frontend_csfml.c +++ b/frontend_csfml.c @@ -116,16 +116,16 @@ int main(int argc, char *argv[]) if (!musicFile) fputs("could not open music file",stderr); - LCR_log("initializing game"); + puts("initializing game"); LCR_gameInit(argc,(const char **) argv); - LCR_log("initializing SFML"); + puts("initializing SFML"); sfVideoMode mode = {LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y,32}; sfEvent event; clock = sfClock_create(); sfClock_restart(clock); - LCR_log("initializing audio"); + puts("initializing audio"); for (int i = 0; i < AUDIO_BUFFER_SIZE; ++i) audioBuffer[i] = 0; @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) sfRenderWindow_display(window); } - LCR_log("ending"); + puts("ending"); if (musicFile) fclose(musicFile); diff --git a/frontend_helper.h b/frontend_helper.h index 6c88473..c92a6fb 100644 --- a/frontend_helper.h +++ b/frontend_helper.h @@ -4,9 +4,10 @@ duplication of code. */ -// TODO: quality presets? +#include +#include -#if PRESET_QUALITY == 1 // ultra low +#if PRESET_QUALITY == 1 // ultra low #define LCR_SETTING_RESOLUTION_X 256 #define LCR_SETTING_RESOLUTION_Y 200 #define LCR_SETTING_POTATO_GRAPHICS 1 @@ -18,7 +19,7 @@ #define LCR_SETTING_TEXTURE_SUBSAMPLE 16 #define LCR_SETTING_FOG 0 #define LCR_SETTING_MUSIC 0 -#elif PRESET_QUALITY == 2 // low +#elif PRESET_QUALITY == 2 // low #define LCR_SETTING_RESOLUTION_X 512 #define LCR_SETTING_RESOLUTION_Y 400 #define LCR_SETTING_RESOLUTION_SUBDIVIDE 2 @@ -28,7 +29,7 @@ #define LCR_SETTING_TEXTURE_SUBSAMPLE 8 #define LCR_SETTING_FOG 0 #define LCR_SETTING_FPS 30 -#elif PRESET_QUALITY == 3 // normal +#elif PRESET_QUALITY == 3 // normal #define LCR_SETTING_RESOLUTION_X 800 #define LCR_SETTING_RESOLUTION_Y 600 #define LCR_SETTING_RESOLUTION_SUBDIVIDE 1 @@ -38,7 +39,7 @@ #define LCR_SETTING_TEXTURE_SUBSAMPLE 4 #define LCR_SETTING_FOG 0 #define LCR_SETTING_FPS 30 -#elif PRESET_QUALITY == 4 // high +#elif PRESET_QUALITY == 4 // high #define LCR_SETTING_RESOLUTION_X 1024 #define LCR_SETTING_RESOLUTION_Y 768 #define LCR_SETTING_RESOLUTION_SUBDIVIDE 1 @@ -50,9 +51,6 @@ #define LCR_SETTING_FPS 45 #endif -#include -#include - #define DATA_FILE_NAME "data" FILE *dataFile = 0; diff --git a/frontend_sdl.c b/frontend_sdl.c index 22daf23..949d6a9 100644 --- a/frontend_sdl.c +++ b/frontend_sdl.c @@ -11,8 +11,8 @@ #define LCR_FPS_GET_MS SDL_GetTicks() // uncomment for FPS measuring #ifdef __EMSCRIPTEN__ - #define LCR_SETTING_RESOLUTION_X 640 - #define LCR_SETTING_RESOLUTION_Y 480 + #define LCR_SETTING_RESOLUTION_X 512 + #define LCR_SETTING_RESOLUTION_Y 400 #define LCR_SETTING_MUSIC 0 #define LCR_SETTING_CAR_SHADOW 0 #define LCR_SETTING_TEXTURE_SUBSAMPLE 4 @@ -173,13 +173,13 @@ int main(int argc, char *argv[]) fputs("could not open music file",stderr); #endif - LCR_log("initializing game"); + puts("initializing game"); LCR_gameInit(argc,(const char **) argv); - LCR_log("initializing SDL"); + puts("initializing SDL"); SDL_Init(SDL_INIT_AUDIO); - LCR_log("initializing audio"); + puts("initializing audio"); SDL_AudioSpec audioSpec; SDL_memset(&audioSpec,0,sizeof(audioSpec)); audioSpec.callback = audioFillCallback; @@ -243,7 +243,7 @@ int main(int argc, char *argv[]) SDL_PumpEvents(); keyboardState = SDL_GetKeyboardState(NULL); - LCR_log("starting game loop"); + puts("starting game loop"); #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(mainLoopIteration,0,1); @@ -252,7 +252,7 @@ int main(int argc, char *argv[]) mainLoopIteration(); #endif - LCR_log("ending"); + puts("ending"); if (musicFile) fclose(musicFile); diff --git a/frontend_x11.c b/frontend_x11.c index 1de2b45..fbdfdcd 100644 --- a/frontend_x11.c +++ b/frontend_x11.c @@ -67,6 +67,8 @@ int main(int argc, char **argv) default: break; } + puts("initializing game"); + LCR_gameInit(argc,(const char **) argv); Display *display = XOpenDisplay(0); @@ -102,6 +104,8 @@ int main(int argc, char **argv) XImage *image = XCreateImage(display,DefaultVisual(display,screen), /*DefaultDepth(display,screen)*/24,ZPixmap,0,framebuffer, LCR_SETTING_RESOLUTION_X,LCR_SETTING_RESOLUTION_Y,8,0); + + puts("starting"); while (running) // main loop { @@ -143,6 +147,8 @@ int main(int argc, char **argv) } } + puts("ending"); + XDestroyImage(image); XCloseDisplay(display); closeDataFile(); diff --git a/game.h b/game.h index addb0df..d2d9ffb 100644 --- a/game.h +++ b/game.h @@ -1224,7 +1224,7 @@ void LCR_gameTimeToStr(uint32_t timeMS, char *str) void LCR_gameDrawPopupMessage(void) { #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 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) { - LCR_LOG1("menu quit"); + LCR_LOG1("menu closed"); + LCR_rendererLoadMapChunks(); LCR_gameSetState(LCR_game.statePrev); } else if (LCR_game.keyStates[LCR_KEY_A] == 1) diff --git a/media/manual.txt b/media/manual.txt index 7c01a9f..39b3b7f 100644 --- a/media/manual.txt +++ b/media/manual.txt @@ -9,37 +9,40 @@ WORK IN PROGRESS 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 -video games (even idie ones), Licar is completely libre, i.e. free as in freedom -(meaning its source code and art assets are available for any use whatsoever), -gratis (free of cost) and its focus lies in being well programmed by adhering to -minimalism and rejecting harmful "modern" programming practices. The game aims -to seflessly bring joy and entertainment to all the people that might enjoy it, -even those who aren't able or willing to pay and/or watch ads, those owning very -old and weak computers and so on. It was made in whole by a single man as a -completely non-commercial program, the development was driven purely by love of -the craft and other living beings to whom it might serve. Licar is also more -than a game, for example it may serve educational purposes or become a basis for -new projects. +video games (even indie ones), Licar is completely libre, i.e. free as in +freedom (meaning its source code and art assets are available for any use +whatsoever), gratis (free of cost) and its focus lies in being well programmed +by adhering to minimalism and rejecting harmful "modern" programming practices. +The game aims to seflessly bring joy and entertainment to all the people that +might enjoy it, even those who aren't able or willing to pay and/or watch ads, +those owning very old and weak computers and so on. It was made in whole by a +single man as a completely non-commercial program, the development was driven +purely by love of the craft and other living beings whom it might serve. Licar +is also more than a game, for example it may serve educational purposes or +become a basis for new projects. -The game runs on many platforms and comes in different versions depending on -what the platforms allow. Some versions may have more features or visual +The game runs on many platforms and comes in different flavors depending on +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 -game, it's probably because of limitations of your platform. On PCs and laptops, -however, everything should be supported. +game, it's probably because of limitations of your platform. On PCs and laptops +running the SDL version, however, everything should be supported. ~~~~~ RUNNING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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. +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 -run the game, you may try to compile the game yourself from the source code. -This is very easy (unlike with most "modern" software), it usually involves -typing a command in command line. For more detail check out the README. +If there isn't a version for your system or for whatever other reason you can't +run the precompiled game, you may try to compile the project yourself from the +source code. This is very simple (unlike with most "modern" software), it +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 -kind of compatibility layer or emulator if there is no native executable for -your system. +kind of compatibility layer (Wine, ...) or emulator if there is no native +executable for your system. 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 diff --git a/renderer.h b/renderer.h index 17d2b4c..911c017 100644 --- a/renderer.h +++ b/renderer.h @@ -2048,7 +2048,7 @@ int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 12; LCR_rendererComputeTextHeight(_FONT_SIZE) + 3 * LCR_FONT_PIXEL_SIZE; ++y) #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 for (int x = 2; x < LCR_EFFECTIVE_RESOLUTION_X - 2; ++x) #endif @@ -2073,7 +2073,7 @@ int stripHeight2 = LCR_EFFECTIVE_RESOLUTION_Y / 12; #if (!LCR_SETTING_POTATO_GRAPHICS) && (!LCR_ANT_RESOLUTION) 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)); #endif