From b3817189ae57901a313bbfb73e75e5e58ae1318f Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Wed, 14 Jan 2026 14:48:32 +0200 Subject: [PATCH 1/9] Renamed timer on english, and renamed preferences (and a bit another stuff) --- src/audio.cc | 6 ++-- src/editor.cc | 12 ++++---- src/game.cc | 46 ++++++++++++++-------------- src/loco.cc | 72 ++++++++++++++++++++++---------------------- src/main.cc | 50 +++++++++++++++---------------- src/menu.cc | 78 ++++++++++++++++++++++++------------------------ src/mouse.cc | 4 +-- src/preference.h | 42 +++++++++++++------------- src/sprite.cc | 6 ++-- src/utils.cc | 40 ++++++++++++------------- src/utils.h | 2 +- 11 files changed, 179 insertions(+), 179 deletions(-) diff --git a/src/audio.cc b/src/audio.cc index 5b812af..f59d972 100644 --- a/src/audio.cc +++ b/src/audio.cc @@ -33,7 +33,7 @@ /*** Variable globales ***/ /*************************/ extern sNewPreference Pref; -extern int Horloge; +extern int currentTime; /*** Constructeur et Destructeur ***/ /***********************************/ @@ -162,10 +162,10 @@ void Audio::Play(eSon So) } if (So == sClic) { - if (Horloge - MemoHorloge <= 120) { + if (currentTime - MemoHorloge <= 120) { return; } - MemoHorloge = Horloge; + MemoHorloge = currentTime; } Mix_PlayChannel(-1, Son[So], 0); diff --git a/src/editor.cc b/src/editor.cc index b6ed9c2..f891bd5 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -43,8 +43,8 @@ extern SDL_Renderer *sdlRenderer; extern Sprite *Sprites; extern sNewPreference Pref; -extern int Horloge; -extern int HorlogeAvant; +extern int currentTime; +extern int previousTime; extern Level level; @@ -65,7 +65,7 @@ eMenu Editor::SDLMain(int NumNiv) Affiche(); // Charge le tableau SDL_RenderPresent(sdlRenderer); - Horloge = SDL_GetTicks(); // Prend l'horloge + currentTime = SDL_GetTicks(); // Prend l'horloge Option = rail; @@ -193,8 +193,8 @@ eMenu Editor::SDLMain(int NumNiv) } // Gère les Horloges et la pose - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Fait l'affichage @@ -409,7 +409,7 @@ void Editor::PrendTouche(int Tou) } // test le niveau - Pref.Niveau = NumN; + Pref.Level = NumN; m_game.SDLMain(); m_mouse.Init(nullptr); Affiche(); diff --git a/src/game.cc b/src/game.cc index 273a27b..951252a 100644 --- a/src/game.cc +++ b/src/game.cc @@ -44,8 +44,8 @@ extern SDL_Renderer *sdlRenderer; extern Sprite *Sprites; extern sNewPreference Pref; -extern int Horloge; -extern int HorlogeAvant; +extern int currentTime; +extern int previousTime; extern Screen Ec; @@ -71,7 +71,7 @@ Game::Game(Audio &sounds, Gamepad &gamepad) : eMenu Game::SDLMain() { eMenu mRet; - int NumN = Pref.Niveau; + int NumN = Pref.Level; Help = true; Load(NumN); // Charge le tableau @@ -79,12 +79,12 @@ eMenu Game::SDLMain() Ec.CleanSpriteAndScreen(fjeu); Pause = true; - Horloge = SDL_GetTicks(); // Prend l'horloge + currentTime = SDL_GetTicks(); // Prend l'horloge DureeJeu = 0; Key = 0; // Met le options de départ du joueur - Pref.NVie = N_VIES_DEP; + Pref.Lifes = N_LIFES_COUNT; Pref.Score = 0; // Prend les evenements @@ -219,13 +219,13 @@ eMenu Game::SDLMain() } // Gère les Horloges et la pose - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); - if (Pause == true || Lo.Mort > Horloge) { - HorlogeAvant = Horloge; + if (Pause == true || Lo.Mort > currentTime) { + previousTime = currentTime; } - DureeJeu += Horloge - HorlogeAvant; + DureeJeu += currentTime - previousTime; // Fait l'affichage DrawLevel(NumN); @@ -238,12 +238,12 @@ eMenu Game::SDLMain() // Fait avancer la loco if (Lo.Mort == -1 && Pause == false) { - Lo.Avance(Horloge - HorlogeAvant, DureeJeu, Touche, T); + Lo.Avance(currentTime - previousTime, DureeJeu, Touche, T); } // Test la fin d'une partie - if (Lo.Mort > -1 && Lo.Mort < Horloge) { // Si est Mort test si doit continuer ou quitter - if (Pref.NVie < 0) { + if (Lo.Mort > -1 && Lo.Mort < currentTime) { // Si est Mort test si doit continuer ou quitter + if (Pref.Lifes < 0) { return mScoreEdit; // Si mort fini } if (Lo.Gagne) { @@ -254,7 +254,7 @@ eMenu Game::SDLMain() #endif NumN++; if (level.N == NumN) { - Pref.Score += Pref.NVie * 100; + Pref.Score += Pref.Lifes * 100; return mScoreEdit; } if (Pref.NiveauMax[Pref.Difficulte] < NumN) { @@ -279,7 +279,7 @@ bool Game::Load(int NivN) { int i; - Pref.Niveau = NivN; + Pref.Level = NivN; // Recopie le tableau for (i = 0; i < LT * HT; i++) { @@ -313,13 +313,13 @@ bool Game::Load(int NivN) // Met la vitesse suivant difficulté switch (Pref.Difficulte) { case Easy: - Pref.Vitesse = Pref.VitesseMoy = VITESSE_MIN; + Pref.Speed = Pref.SpeedAverage = SPEED_MIN; break; case Hard: - Pref.Vitesse = Pref.VitesseMoy = VITESSE_MAX; + Pref.Speed = Pref.SpeedAverage = SPEED_MAX; break; default: - Pref.Vitesse = Pref.VitesseMoy = VITESSE_MOY; + Pref.Speed = Pref.SpeedAverage = SPEED_AVERAGE; } return DrawLevel(NivN); @@ -374,7 +374,7 @@ bool Game::DrawLevel(int NivN) AfficheText(740, 260, T_options, Sprites[fjeu].Image[0]); AfficheText(740, 340, T_lives, Sprites[fjeu].Image[0]); - AfficheChiffre(740, 140, Pref.Niveau + 1, Sprites[fjeu].Image[0]); + AfficheChiffre(740, 140, Pref.Level + 1, Sprites[fjeu].Image[0]); return true; } @@ -566,14 +566,14 @@ void Game::AfficheEcran() } // Affiche tableau de bord - Ec.PrintOptions(Pref.NVie, Pref.Score); - if (Pref.EcartWagon < ECARTWAGON_MOY) { + Ec.PrintOptions(Pref.Lifes, Pref.Score); + if (Pref.WagonGap < WAGON_GAP_MIN) { Ec.PrintSprite(pluscourt, (DureeJeu * 40 / 1000) % 50, 715, 295); } - if (Pref.EcartWagon > ECARTWAGON_MOY) { + if (Pref.WagonGap > WAGON_GAP_AVERAGE) { Ec.PrintSprite(pluslong, (DureeJeu * 40 / 1000) % 50, 715, 295); } - if (Pref.VitesseMoy > Pref.Vitesse) { + if (Pref.SpeedAverage > Pref.Speed) { Ec.PrintSprite(vitesse, (DureeJeu * 40 / 1000 + 7) % 50, 765, 295); } } diff --git a/src/loco.cc b/src/loco.cc index 1889a76..2783474 100644 --- a/src/loco.cc +++ b/src/loco.cc @@ -36,7 +36,7 @@ /*** Variables globales ***/ /**************************/ extern sNewPreference Pref; -extern int Horloge; +extern int currentTime; extern int MasqueK; int AddDir[] = { -1, 1, -LT, LT }; @@ -61,7 +61,7 @@ void Loco::Init(int Pos, int Direction) Vitesse = Reduit = Alonge = 0; // Pas d'alongement Mort = -1; Gagne = false; - Pref.EcartWagon = ECARTWAGON_MOY; + Pref.WagonGap = WAGON_GAP_AVERAGE; // Initialise les variables for (i = 0; i < 256; i++) { @@ -229,7 +229,7 @@ void Loco::Display(Screen &Ec) } // Met l'ecart entre les wagons - ltrain += Pref.EcartWagon; + ltrain += Pref.WagonGap; } } @@ -259,7 +259,7 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) } } if (Gagne) { - Mort = Horloge + DUREE_PAUSE; + Mort = currentTime + PAUSE_DURATION; m_audio.Play(sEnd); } break; @@ -271,7 +271,7 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) Reduit = DureeJeu - 1; } else { - Alonge = DureeJeu + DUREE_ALONGE; + Alonge = DureeJeu + ALONGE_DURATION; } break; case C_Reduit: // Si réduit la loco @@ -281,19 +281,19 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) Alonge = DureeJeu - 1; } else { - Reduit = DureeJeu + DUREE_REDUIT; + Reduit = DureeJeu + REDUCED_DURATION; } break; case C_Speed: // Si Vitesse m_audio.Play(sSpeed); Tableau[T[PLoco].P] = 1; // efface l'option Pref.Score += 30; - Vitesse = DureeJeu + DUREE_VITESSE; + Vitesse = DureeJeu + SPEED_DURATION; break; case C_Live: // Si Vie m_audio.Play(sLive); Tableau[T[PLoco].P] = 1; // efface l'option - Pref.NVie++; + Pref.Lifes++; break; } @@ -307,10 +307,10 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) Ec2 = vx * vx + vy * vy; // Si colition le signale - if (Mort < Horloge && (Ec1 < RAYON_TOUCHE || Ec2 <= RAYON_TOUCHE)) { + if (Mort < currentTime && (Ec1 < RAYON_TOUCHE || Ec2 <= RAYON_TOUCHE)) { m_audio.Play(sCrash); - Pref.NVie--; - Mort = Horloge + DUREE_PAUSE; + Pref.Lifes--; + Mort = currentTime + PAUSE_DURATION; } } } @@ -321,7 +321,7 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) void Loco::Avance(int Duree, long DureeJeu, int *Touche, int *Tableau) { int i; - float Dist = Pref.VitesseMoy * (float)(Duree) / 1000.0; + float Dist = Pref.SpeedAverage * (float)(Duree) / 1000.0; MemoDuree = (float)(Duree); @@ -329,54 +329,54 @@ void Loco::Avance(int Duree, long DureeJeu, int *Touche, int *Tableau) // Test si doit Réduire le wagon if (Reduit > DureeJeu) { - if (Pref.EcartWagon > ECARTWAGON_MIN) { // Si doit réduire - Pref.EcartWagon -= (float)(Duree) * (Pref.VitesseMoy * 0.8 / (float)(NWagon - 1)) / 1000.0; - if (Pref.EcartWagon < ECARTWAGON_MIN) { - Pref.EcartWagon = ECARTWAGON_MIN; + if (Pref.WagonGap > WAGON_GAP_MIN) { // Si doit réduire + Pref.WagonGap -= (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon - 1)) / 1000.0; + if (Pref.WagonGap < WAGON_GAP_MIN) { + Pref.WagonGap = WAGON_GAP_MIN; } } } else { // Si temps est passé - if (Pref.EcartWagon < ECARTWAGON_MOY) { // Si doit ralonger le wagon - Pref.EcartWagon += (float)(Duree) * (Pref.VitesseMoy * 0.8 / (float)(NWagon)) / 1000.0; - if (Pref.EcartWagon > ECARTWAGON_MOY) { - Pref.EcartWagon = ECARTWAGON_MOY; + if (Pref.WagonGap < WAGON_GAP_AVERAGE) { // Si doit ralonger le wagon + Pref.WagonGap += (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon)) / 1000.0; + if (Pref.WagonGap > WAGON_GAP_AVERAGE) { + Pref.WagonGap = WAGON_GAP_AVERAGE; } } } // Test si doit Ralonger le wagon if (Alonge > DureeJeu) { - if (Pref.EcartWagon < ECARTWAGON_MAX) { // Si doit Ralonger - Pref.EcartWagon += (float)(Duree) * (Pref.VitesseMoy * 0.8 / (float)(NWagon)) / 1000.0; - if (Pref.EcartWagon > ECARTWAGON_MAX) { - Pref.EcartWagon = ECARTWAGON_MAX; + if (Pref.WagonGap < WAGON_GAP_MAX) { // Si doit Ralonger + Pref.WagonGap += (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon)) / 1000.0; + if (Pref.WagonGap > WAGON_GAP_MAX) { + Pref.WagonGap = WAGON_GAP_MAX; } } } else { // Si temps est passé - if (Pref.EcartWagon > ECARTWAGON_MOY) { // Si doit ralonger le wagon - Pref.EcartWagon -= (float)(Duree) * (Pref.VitesseMoy * 0.8 / (float)(NWagon - 1)) / 1000.0; - if (Pref.EcartWagon < ECARTWAGON_MOY) { - Pref.EcartWagon = ECARTWAGON_MOY; + if (Pref.WagonGap > WAGON_GAP_AVERAGE) { // Si doit ralonger le wagon + Pref.WagonGap -= (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon - 1)) / 1000.0; + if (Pref.WagonGap < WAGON_GAP_AVERAGE) { + Pref.WagonGap = WAGON_GAP_AVERAGE; } } } // Test si doit modifier la vitesse de la loco if (Vitesse > DureeJeu) { - if (Pref.VitesseMoy < Pref.Vitesse * 2) { // Si doit accelerer - Pref.VitesseMoy += (float)(Duree) / 40.0; - if (Pref.VitesseMoy > Pref.Vitesse * 2) { - Pref.VitesseMoy = Pref.Vitesse * 2; + if (Pref.SpeedAverage < Pref.Speed * 2) { // Si doit accelerer + Pref.SpeedAverage += (float)(Duree) / 40.0; + if (Pref.SpeedAverage > Pref.Speed * 2) { + Pref.SpeedAverage = Pref.Speed * 2; } } } else { - if (Pref.VitesseMoy > Pref.Vitesse) { // Si doit ralentir - Pref.VitesseMoy -= (float)(Duree) / 40.0; - if (Pref.VitesseMoy < Pref.Vitesse) { - Pref.VitesseMoy = Pref.Vitesse; + if (Pref.SpeedAverage > Pref.Speed) { // Si doit ralentir + Pref.SpeedAverage -= (float)(Duree) / 40.0; + if (Pref.SpeedAverage < Pref.Speed) { + Pref.SpeedAverage = Pref.Speed; } } } diff --git a/src/main.cc b/src/main.cc index 1100443..53ba542 100644 --- a/src/main.cc +++ b/src/main.cc @@ -33,7 +33,7 @@ #include #include -#include "config.h" +#include "config.h" // Done #include "preference.h" #include "game.h" #include "gamepad.h" @@ -44,37 +44,37 @@ #include "menu.h" #include "level.h" #include "editor.h" -#include "utils.h" +#include "utils.h" // Done -/*** Variables globales ***/ +/*** Global variables ***/ /************************/ -SDL_Window *sdlWindow; // Pointe sur l'écran video -SDL_Renderer *sdlRenderer; // Pointe sur l'écran video +SDL_Window *sdlWindow; // Screen video pointer +SDL_Renderer *sdlRenderer; // Screen video pointer char Titre[] = "Li-ri V" VERSION; -Sprite *Sprites = nullptr; // Pointe sur les sprites -int NSprites = 0; // Nombre de sprites en mémoire -Screen Ec; // Pointe sur les 2 buffets vidéo -sNewPreference Pref; // Tableau des préférences. -Level level; // Gère les niveaux +Sprite *Sprites = nullptr; // Sprites pointer +int NSprites = 0; // Number of sprites in memory +Screen Ec; // 2 Video buffer pointer TODO: RENAME +sNewPreference Pref; // Preference table. +Level level; // Level class -int Horloge = 0; // Horloges du jeu -int HorlogeAvant = 0; +int currentTime = 0; // Game clock +int previousTime = 0; #if defined(__unix__) || defined(__HAIKU__) -char DefPath[256]; // Chemin par defaut dans arg +char DefPath[256]; // Default path #endif -/*** Initialise les preferences ***/ -/**********************************/ +/*** Initialize preferences ***/ +/******************************/ void InitPref() { #if defined(__unix__) || defined(__HAIKU__) DefPath[0] = 0; #endif - for (int i = 0; i < 8; i++) { // Vide les scores + for (int i = 0; i < 8; i++) { // Empty the scores Pref.Sco[i].Score = 0; Pref.Sco[i].Name[0] = 0; } @@ -82,14 +82,14 @@ void InitPref() Utils::LoadPref(); } -/*** Preogramme principale ***/ -/*****************************/ +/*** Main program ***/ +/********************/ int main(int narg, char *argv[]) { int i; eMenu RetM, RetMenu = mMenu; - // Initialise les préferences + // Initialize preferences InitPref(); #if defined(__unix__) || defined(__HAIKU__) if (narg > 1) { @@ -103,10 +103,10 @@ int main(int narg, char *argv[]) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s", SDL_GetError()); exit(-1); } - // Ferme le programme correctement quand quit + // Close the program properly when quitting atexit(SDL_Quit); - // Demande la resolution Video + // Set resolution int vOption = SDL_WINDOW_RESIZABLE; if (Pref.FullScreen) { vOption |= SDL_WINDOW_FULLSCREEN_DESKTOP; @@ -117,7 +117,7 @@ int main(int narg, char *argv[]) SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); SDL_RenderSetLogicalSize(sdlRenderer, 800, 600); - SDL_ShowCursor(0); // Masque le curseur + SDL_ShowCursor(0); // Hide cursor Audio audio; audio.Init(); @@ -141,11 +141,11 @@ int main(int narg, char *argv[]) Menu MainMenu { game, audio, mouse, gamepad }; game.setMenu(&MainMenu); - HorlogeAvant = Horloge = SDL_GetTicks(); + previousTime = currentTime = SDL_GetTicks(); srand(SDL_GetTicks()); // ask locale if first run - if (Pref.Langue == -1) { + if (Pref.Language == -1) { RetMenu = MainMenu.SDLMain_Language(); LoadLangue(); } @@ -197,7 +197,7 @@ int main(int narg, char *argv[]) } delete[] Sprites; - Utils::SauvePref(); + Utils::SavePref(); SDL_DestroyRenderer(sdlRenderer); SDL_DestroyWindow(sdlWindow); diff --git a/src/menu.cc b/src/menu.cc index 6432693..abe62ac 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -51,8 +51,8 @@ /*** Variables globales ***/ /**************************/ -extern int Horloge; -extern int HorlogeAvant; +extern int currentTime; +extern int previousTime; extern SDL_Window *sdlWindow; extern SDL_Renderer *sdlRenderer; extern Sprite *Sprites; @@ -68,10 +68,10 @@ void Sleeping() { int delay; - if ((Horloge - HorlogeAvant) < (1000 / 60)) { - delay = 1000 / 60 - (Horloge - HorlogeAvant); + if ((currentTime - previousTime) < (1000 / 60)) { + delay = 1000 / 60 - (currentTime - previousTime); SDL_Delay(delay); - Horloge = SDL_GetTicks(); + currentTime = SDL_GetTicks(); } } @@ -195,8 +195,8 @@ eMenu Menu::SDLMain() } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -221,11 +221,11 @@ eMenu Menu::SDLMain_Language() int Ecart; int i; int x, y; - int const OldLangue = Pref.Langue; + int const OldLangue = Pref.Language; // Initialisations Divers m_mouse.Init(Menu_Py); // Initialise la sourie - PyE = Pref.Langue; + PyE = Pref.Language; if (PyE == -1) { PyE = 1; } @@ -286,8 +286,8 @@ eMenu Menu::SDLMain_Language() switch (event.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_AC_BACK: // Android back button - if (Pref.Langue == -1) { - Pref.Langue = PyE; + if (Pref.Language == -1) { + Pref.Language = PyE; } return mMenu; case SDLK_UP: @@ -320,8 +320,8 @@ eMenu Menu::SDLMain_Language() case ' ': case SDLK_RETURN: case SDLK_KP_ENTER: - Pref.Langue = PyE; - if (Pref.Langue != OldLangue) { + Pref.Language = PyE; + if (Pref.Language != OldLangue) { LoadLangue(); } return mMenu; @@ -337,8 +337,8 @@ eMenu Menu::SDLMain_Language() } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -591,8 +591,8 @@ eMenu Menu::SDLMain_Options() // SDL_RenderClear(sdlRenderer); // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -607,15 +607,15 @@ eMenu Menu::SDLMain_Options() Ec.PrintSprite(fleches, 4, 450, 300); } - NumSp = (Horloge / 30) % 25; + NumSp = (currentTime / 30) % 25; Ec.PrintSprite(bruitage, NumSp, 150, 110); - NumSp = (Horloge / 30) % 25; + NumSp = (currentTime / 30) % 25; Ec.PrintSprite(music, NumSp, 150, 200); - NumSp = (Horloge / 50) % 50; + NumSp = (currentTime / 50) % 50; Ec.PrintSprite(monde, NumSp, 180, 400); N = (int)(Pref.Volume * 10 + 1) / SDL_MIX_MAXVOLUME; - NumSp = (Horloge / 50) % 40 + 120; + NumSp = (currentTime / 50) % 40 + 120; for (i = 0; i < N; i++) { if (i == N - 1) { Ec.PrintSprite(locomotive, NumSp, (690 - 300) / 10 * i + 300, 110); @@ -763,8 +763,8 @@ eMenu Menu::SDLMain_Speed() } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -788,7 +788,7 @@ eMenu Menu::SDLMain_Level() m_mouse.Init(Menu_Py); // Initialise la sourie PyE = 0; Niv = Pref.NiveauMax[Pref.Difficulte]; - Pref.Niveau = 0; + Pref.Level = 0; // Prend les evenements do { @@ -865,7 +865,7 @@ eMenu Menu::SDLMain_Level() case 0: return mGame; case 1: - Pref.Niveau = Niv; + Pref.Level = Niv; return mGame; case 2: return mMenu; @@ -893,8 +893,8 @@ eMenu Menu::SDLMain_Level() } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -1088,11 +1088,11 @@ eMenu Menu::SDLMain_HR() case 0: m_audio.Play(sEnd); Pref.Score += 50; - Fini = Horloge + 2000; + Fini = currentTime + 2000; break; case 1: m_audio.Play(sLose); - Fini = Horloge + 2000; + Fini = currentTime + 2000; break; } break; @@ -1108,13 +1108,13 @@ eMenu Menu::SDLMain_HR() } // Test si fini - if (Fini != -1 && Fini < Horloge) { + if (Fini != -1 && Fini < currentTime) { return mGame; } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -1260,8 +1260,8 @@ eMenu Menu::SDLMain_InGame() } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); // Gère l'Affichage @@ -1413,14 +1413,14 @@ eMenu Menu::SDLMain_Score(bool EditScore) } // Gère les variables - HorlogeAvant = Horloge; - Horloge = SDL_GetTicks(); + previousTime = currentTime; + currentTime = SDL_GetTicks(); Sleeping(); if (EditScore) { // Gère l'affiche pour l'édition des scores AfficheString(140, 120 + NEdit * (360 / 7), Pref.Sco[NEdit].Name); - i = (Horloge / 50) % 20; // Affiche les curseurs + i = (currentTime / 50) % 20; // Affiche les curseurs Ec.PrintSprite(fleche_gauche, i, 110, 120 + NEdit * (360 / 7)); Ec.PrintSprite(fleche_droite, i, 180 + LongueurString(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); } @@ -1440,7 +1440,7 @@ eMenu Menu::SDLMain_Score(bool EditScore) /**********************************/ void Menu::Print_Main(int Centre) const { - int const NumSp = (Horloge / 50) % 20; + int const NumSp = (currentTime / 50) % 20; int const x1 = Menu_Py[PyE].DepX - 25; int const x2 = (Centre - x1) + Centre; int const y = (Menu_Py[PyE].FinY + Menu_Py[PyE].DepY) / 2; @@ -1453,7 +1453,7 @@ void Menu::Print_Main(int Centre) const /*****************************************/ void Menu::Affiche_Main_Centre() const { - int const NumSp = (Horloge / 50) % 20; + int const NumSp = (currentTime / 50) % 20; int const x1 = Menu_Py[PyE].DepX - 5; int const x2 = Menu_Py[PyE].FinX + 5; int const y = (Menu_Py[PyE].FinY + Menu_Py[PyE].DepY) / 2; diff --git a/src/mouse.cc b/src/mouse.cc index 952e8ad..9dff259 100644 --- a/src/mouse.cc +++ b/src/mouse.cc @@ -31,7 +31,7 @@ /*** Variables Globales ***/ /**************************/ -extern int Horloge; +extern int currentTime; extern Screen Ec; extern SDL_Window *sdlWindow; @@ -125,7 +125,7 @@ void Mouse::GetEvent(SDL_Event &event, int &pPy) void Mouse::Print() const { int X = Px, Y = Py; - int const NumSp = (Horloge / 50) % 20; + int const NumSp = (currentTime / 50) % 20; // Corrige la position du curseur au cas ou déborde de l'écran if (X < 5) { diff --git a/src/preference.h b/src/preference.h index 76366bc..ea63680 100644 --- a/src/preference.h +++ b/src/preference.h @@ -26,20 +26,20 @@ #include // for SDL_MIX_MAXVOLUME -#define VITESSE_MAX 180.0 -#define VITESSE_MOY 120.0 -#define VITESSE_MIN 80.0 -#define DUREE_VITESSE (10 * 1000) +#define SPEED_MAX 180.0 +#define SPEED_AVERAGE 120.0 +#define SPEED_MIN 80.0 +#define SPEED_DURATION (10 * 1000) -#define DUREE_PAUSE (3 * 1000) +#define PAUSE_DURATION (3 * 1000) -#define DUREE_REDUIT (10 * 1000) -#define DUREE_ALONGE (10 * 1000) -#define ECARTWAGON_MAX 27.0 -#define ECARTWAGON_MOY 13.0 -#define ECARTWAGON_MIN 4.0 +#define REDUCED_DURATION (10 * 1000) +#define ALONGE_DURATION (10 * 1000) +#define WAGON_GAP_MAX 27.0 +#define WAGON_GAP_AVERAGE 13.0 +#define WAGON_GAP_MIN 4.0 -#define N_VIES_DEP 3 +#define N_LIFES_COUNT 3 #define RAYON_TOUCHE (32 * 32) @@ -84,8 +84,8 @@ struct sScore struct sOldPreference { e_Difficulte Difficulte; // Difficulté de la partie (Vitesse) - int Niveau; // Niveau du joueur - int NVie; // Nombre de vie du joueur + int Level; // Niveau du joueur + int Lifes; // Nombre de vie du joueur int Score; // Score du joueur double Vitesse; // Vitesse suivant le niveau double VitesseMoy; // Vitesse en cours de la loco @@ -99,26 +99,26 @@ struct sOldPreference struct sScore Sco[8]; // Mémorise les scores }; -struct sNewPreference +struct sNewPreference // Here too { e_Difficulte Difficulte { Normal }; // current game difficulty - int Niveau; // current level - int NVie { N_VIES_DEP }; // current number of life + int Level; // current level + int Lifes { N_LIFES_COUNT }; // current number of life int Score; // current score - double Vitesse { VITESSE_MOY }; // Vitesse suivant le niveau - double VitesseMoy { VITESSE_MOY }; // Vitesse en cours de la loco - float EcartWagon { ECARTWAGON_MOY }; // ecart en pixels entre 2 wagons + double Speed { SPEED_AVERAGE }; // Vitesse suivant le niveau + double SpeedAverage { SPEED_AVERAGE }; // Vitesse en cours de la loco + float WagonGap { WAGON_GAP_AVERAGE }; // ecart en pixels entre 2 wagons int NLangues; // Nombre de langues disponible int NiveauMax[3] { 0, 0, 0 }; // One per difficulty int FullScreen { true }; - int Langue { -1 }; // locale index + int Language { -1 }; // locale index float Volume { (float)SDL_MIX_MAXVOLUME }; // audio volume float VolumeM { (float)SDL_MIX_MAXVOLUME }; // music volume struct sScore Sco[8]; // store scores int HumanRightsQuiz { 1 }; // enable the human rights questions at the end of a level }; -enum eMenu { +enum eMenu { // TODO: Rename mMenu, mMenuJeux, mMenuSpeed, diff --git a/src/sprite.cc b/src/sprite.cc index ea3b243..3dc2787 100644 --- a/src/sprite.cc +++ b/src/sprite.cc @@ -78,10 +78,10 @@ bool LoadLangue() unsigned char *Buf; char PathFile[512]; - strcpy(PathFile, Langue[Pref.Langue]); + strcpy(PathFile, Langue[Pref.Language]); Utils::GetPath(PathFile); if (Utils::FileExists(PathFile) == false) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find '%s'", Langue[Pref.Langue]); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find '%s'", Langue[Pref.Language]); return false; } L = Utils::LoadFile(PathFile, Buf); @@ -203,7 +203,7 @@ bool LoadSprites() // *** Charge la langue *** // ************************ - if (Pref.Langue != -1) { + if (Pref.Language != -1) { LoadLangue(); } diff --git a/src/utils.cc b/src/utils.cc index daa8225..bc3ffb7 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -39,15 +39,15 @@ #include "SimpleIni.h" -/*** Variables globales ***/ +/*** Global variables ***/ /**************************/ extern sNewPreference Pref; #if defined(__unix__) || defined(__HAIKU__) -extern char DefPath[]; // Chemin par defaut dans arg +extern char DefPath[]; // Default path in argument #endif -/*** Définition générals ***/ -/***************************/ +/*** General defines ***/ +/************************/ #ifdef __APPLE__ #define MAC_LINUX #endif @@ -60,7 +60,7 @@ extern char DefPath[]; // Chemin par defaut dans arg #define MAC_LINUX #endif -/*** Test si un fichier exite ***/ +/*** Check if the file exists ***/ /********************************/ bool Utils::FileExists(const char *Path) { @@ -74,8 +74,8 @@ bool Utils::FileExists(const char *Path) return true; } -/*** Charge un fichier en Mémoire ***/ -/************************************/ +/*** Load a file in memory ***/ +/*****************************/ long Utils::LoadFile(const char *Path, unsigned char *&Buf) { SDL_RWops *file = SDL_RWFromFile(Path, "rb"); @@ -116,8 +116,8 @@ long Utils::LoadFile(const char *Path, unsigned char *&Buf) return L; } -/*** Sauve un Fichier ***/ -/************************/ +/*** Save a file ***/ +/*******************/ bool Utils::SaveFile(const char *Path, char *Buf, long L) { FILE *file; @@ -150,8 +150,8 @@ bool Utils::SaveFile(const char *Path, char *Buf, long L) return true; } -/*** Met le bon chemin pour charger un fichier ***/ -/*************************************************/ +/*** Add the path to the filename depending on the OS (sprites, levels) ***/ +/**************************************************************************/ #if (defined(__unix__) || defined(ANDROID)) || defined(__HAIKU__) && !defined(__AMIGAOS4__) // Version Linux void Utils::GetPath(char *Path) @@ -221,7 +221,7 @@ void Utils::GetPath(char *Path) #endif #ifdef _WIN32 -// Version Windows , chemin directe +// Windows version, direct path void Utils::GetPath(char *Path) { char Provi[512]; @@ -237,8 +237,8 @@ void Utils::GetPath(char *Path) } #endif -/*** Charge les préferences ***/ -/******************************/ +/*** Load preferences ***/ +/************************/ bool Utils::LoadPref() { int L; @@ -264,7 +264,7 @@ bool Utils::LoadPref() } pv = ini.GetValue("main", "locale"); if (pv) { - Pref.Langue = std::stoi(pv); + Pref.Language = std::stoi(pv); } pv = ini.GetValue("main", "audioVolume"); if (pv) { @@ -313,7 +313,7 @@ bool Utils::LoadPref() memcpy((char *)&oldPref, Provi, L); delete[] Provi; Pref.FullScreen = oldPref.FullScreen; - Pref.Langue = oldPref.Langue; + Pref.Language = oldPref.Langue; Pref.Volume = oldPref.Volume; Pref.VolumeM = oldPref.VolumeM; // Try to restore max difficulty from the level stored in conf @@ -332,9 +332,9 @@ bool Utils::LoadPref() return false; } -/*** Sauve les preferences ***/ -/*****************************/ -void Utils::SauvePref() +/*** Save preferences ***/ +/************************/ +void Utils::SavePref() { char PathPref[512]; char *PrefFolder = SDL_GetPrefPath("Li-Ri", "Li-Ri"); @@ -343,7 +343,7 @@ void Utils::SauvePref() SDL_free(PrefFolder); CSimpleIniA ini(true); // true for unicode ini.SetValue("main", "fullscreen", std::to_string(Pref.FullScreen).c_str()); - ini.SetValue("main", "locale", std::to_string(Pref.Langue).c_str()); + ini.SetValue("main", "locale", std::to_string(Pref.Language).c_str()); ini.SetValue("main", "audioVolume", std::to_string(Pref.Volume).c_str()); ini.SetValue("main", "musicVolume", std::to_string(Pref.VolumeM).c_str()); ini.SetValue("main", "humanRightsQuiz", std::to_string(Pref.HumanRightsQuiz).c_str()); diff --git a/src/utils.h b/src/utils.h index dbf0c17..0708fc0 100644 --- a/src/utils.h +++ b/src/utils.h @@ -36,7 +36,7 @@ class Utils static void GetPath(char *Path); // Add the path to the filename depending on the OS (sprites, levels) static bool LoadPref(); // Load preferences - static void SauvePref(); // Save preferences + static void SavePref(); // Save preferences static void doScreenshot(SDL_Renderer *renderer); }; From ecbbaf914a2001766d236620ef4014ba9d03786d Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Wed, 14 Jan 2026 17:08:37 +0200 Subject: [PATCH 2/9] More translation's in preferences --- src/game.cc | 8 ++++---- src/main.cc | 4 ++-- src/menu.cc | 38 +++++++++++++++++++------------------- src/preference.h | 26 +++++++++++++------------- src/sprite.cc | 8 ++++---- src/utils.cc | 18 +++++++++--------- 6 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/game.cc b/src/game.cc index 951252a..942e31e 100644 --- a/src/game.cc +++ b/src/game.cc @@ -257,8 +257,8 @@ eMenu Game::SDLMain() Pref.Score += Pref.Lifes * 100; return mScoreEdit; } - if (Pref.NiveauMax[Pref.Difficulte] < NumN) { - Pref.NiveauMax[Pref.Difficulte] = NumN; + if (Pref.LevelMax[Pref.Difficulty] < NumN) { + Pref.LevelMax[Pref.Difficulty] = NumN; } } m_sounds.NextMusic(); @@ -287,7 +287,7 @@ bool Game::Load(int NivN) } // Laisse ou efface la vie suivant le niveau - switch (Pref.Difficulte) { + switch (Pref.Difficulty) { case Easy: i = 5; break; @@ -311,7 +311,7 @@ bool Game::Load(int NivN) MasqueK = 0; // Met la vitesse suivant difficulté - switch (Pref.Difficulte) { + switch (Pref.Difficulty) { case Easy: Pref.Speed = Pref.SpeedAverage = SPEED_MIN; break; diff --git a/src/main.cc b/src/main.cc index 53ba542..815fd2a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -156,7 +156,7 @@ int main(int narg, char *argv[]) case mMenu: RetM = MainMenu.SDLMain(); break; - case mLangue: + case mLanguage: RetM = MainMenu.SDLMain_Language(); break; case mOption: @@ -171,7 +171,7 @@ int main(int narg, char *argv[]) case mMenuSpeed: RetM = MainMenu.SDLMain_Speed(); break; - case mMenuNiveau: + case mMenuLevel: RetM = MainMenu.SDLMain_Level(); break; case mGame: diff --git a/src/menu.cc b/src/menu.cc index abe62ac..a375a7f 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -236,15 +236,15 @@ eMenu Menu::SDLMain_Language() // Affiche les langues possibles NCol = 3; - if (Pref.NLangues % NCol == 0) { - NL = Pref.NLangues / NCol; + if (Pref.NLanguages % NCol == 0) { + NL = Pref.NLanguages / NCol; } else { - NL = Pref.NLangues / NCol + 1; + NL = Pref.NLanguages / NCol + 1; } Ecart = 600 / (NL + 1); - for (i = 0; i < Pref.NLangues; i++) { + for (i = 0; i < Pref.NLanguages; i++) { x = (i / NL) * (800 / 3) + (800 / 6); y = (i % NL) * Ecart + Ecart; @@ -252,7 +252,7 @@ eMenu Menu::SDLMain_Language() AddBouton(i, (e_Sprite)(T_Langue + i), x, y); } - Menu_Py[Pref.NLangues].DepX = -1; + Menu_Py[Pref.NLanguages].DepX = -1; // Efface le fond SDL_RenderPresent(sdlRenderer); @@ -261,7 +261,7 @@ eMenu Menu::SDLMain_Language() do { SDL_RenderClear(sdlRenderer); Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); - for (i = 0; i < Pref.NLangues; i++) { + for (i = 0; i < Pref.NLanguages; i++) { x = (i / NL) * (800 / 3) + (800 / 6); y = (i % NL) * Ecart + Ecart; @@ -293,12 +293,12 @@ eMenu Menu::SDLMain_Language() case SDLK_UP: PyE--; if (PyE < 0) { - PyE = Pref.NLangues - 1; + PyE = Pref.NLanguages - 1; } break; case SDLK_DOWN: PyE++; - if (PyE >= Pref.NLangues) { + if (PyE >= Pref.NLanguages) { PyE = 0; } break; @@ -308,7 +308,7 @@ eMenu Menu::SDLMain_Language() } break; case SDLK_RIGHT: - if (PyE + NL < Pref.NLangues) { + if (PyE + NL < Pref.NLanguages) { PyE += NL; } break; @@ -741,14 +741,14 @@ eMenu Menu::SDLMain_Speed() case SDLK_KP_ENTER: switch (PyE) { case 0: - Pref.Difficulte = Easy; - return Pref.NiveauMax[Pref.Difficulte] > 0 ? mMenuNiveau : mGame; + Pref.Difficulty = Easy; + return Pref.LevelMax[Pref.Difficulty] > 0 ? mMenuLevel : mGame; case 1: - Pref.Difficulte = Normal; - return Pref.NiveauMax[Pref.Difficulte] > 0 ? mMenuNiveau : mGame; + Pref.Difficulty = Normal; + return Pref.LevelMax[Pref.Difficulty] > 0 ? mMenuLevel : mGame; case 2: - Pref.Difficulte = Hard; - return Pref.NiveauMax[Pref.Difficulte] > 0 ? mMenuNiveau : mGame; + Pref.Difficulty = Hard; + return Pref.LevelMax[Pref.Difficulty] > 0 ? mMenuLevel : mGame; } break; default: @@ -787,7 +787,7 @@ eMenu Menu::SDLMain_Level() // Initialisations Divers m_mouse.Init(Menu_Py); // Initialise la sourie PyE = 0; - Niv = Pref.NiveauMax[Pref.Difficulte]; + Niv = Pref.LevelMax[Pref.Difficulty]; Pref.Level = 0; // Prend les evenements @@ -848,7 +848,7 @@ eMenu Menu::SDLMain_Level() PyE = 1; break; case SDLK_RIGHT: - if (Niv < Pref.NiveauMax[Pref.Difficulte]) { + if (Niv < Pref.LevelMax[Pref.Difficulty]) { Niv++; } PyE = 1; @@ -875,7 +875,7 @@ eMenu Menu::SDLMain_Level() } break; case 4: - if (Niv < Pref.NiveauMax[Pref.Difficulte]) { + if (Niv < Pref.LevelMax[Pref.Difficulty]) { Niv++; } break; @@ -913,7 +913,7 @@ eMenu Menu::SDLMain_Level() Ec.PrintSprite(fleches, 0, 330, 380); } - if (Niv < Pref.NiveauMax[Pref.Difficulte]) { + if (Niv < Pref.LevelMax[Pref.Difficulty]) { if (PyE == 4) { Ec.PrintSprite(fleches, 5, 470, 380); } diff --git a/src/preference.h b/src/preference.h index ea63680..684b5ce 100644 --- a/src/preference.h +++ b/src/preference.h @@ -65,13 +65,13 @@ #define C_Live 6 #define C_Fin 7 -enum e_Difficulte { +enum e_Difficulty { Easy, Normal, Hard }; -/*** Mémorise un score ***/ +/*** Remember score ***/ #define LSCOREMAX 460 struct sScore @@ -80,10 +80,10 @@ struct sScore char Name[80]; }; -/*** Structure des preferences Générales ***/ +/*** Preferences structures ***/ struct sOldPreference { - e_Difficulte Difficulte; // Difficulté de la partie (Vitesse) + e_Difficulty Difficulte; // Difficulté de la partie (Vitesse) int Level; // Niveau du joueur int Lifes; // Nombre de vie du joueur int Score; // Score du joueur @@ -101,15 +101,15 @@ struct sOldPreference struct sNewPreference // Here too { - e_Difficulte Difficulte { Normal }; // current game difficulty + e_Difficulty Difficulty { Normal }; // current game difficulty int Level; // current level int Lifes { N_LIFES_COUNT }; // current number of life int Score; // current score - double Speed { SPEED_AVERAGE }; // Vitesse suivant le niveau - double SpeedAverage { SPEED_AVERAGE }; // Vitesse en cours de la loco - float WagonGap { WAGON_GAP_AVERAGE }; // ecart en pixels entre 2 wagons - int NLangues; // Nombre de langues disponible - int NiveauMax[3] { 0, 0, 0 }; // One per difficulty + double Speed { SPEED_AVERAGE }; // speed ​​depending on level + double SpeedAverage { SPEED_AVERAGE }; // current speed of the locomotive + float WagonGap { WAGON_GAP_AVERAGE }; // size in pixels between wagons + int NLanguages; // number of languages ​​available + int LevelMax[3] { 0, 0, 0 }; // One per difficulty int FullScreen { true }; int Language { -1 }; // locale index float Volume { (float)SDL_MIX_MAXVOLUME }; // audio volume @@ -120,10 +120,10 @@ struct sNewPreference // Here too enum eMenu { // TODO: Rename mMenu, - mMenuJeux, + mMenuGame, mMenuSpeed, - mMenuNiveau, - mLangue, + mMenuLevel, + mLanguage, mGame, mScore, mScoreEdit, diff --git a/src/sprite.cc b/src/sprite.cc index 3dc2787..b2a1eba 100644 --- a/src/sprite.cc +++ b/src/sprite.cc @@ -140,20 +140,20 @@ bool LoadSprites() NSp = (int)(Buf[0]) * 256 + (int)(Buf[1]); NSp += N_SPRITESFOND + 2; NTextes = (int)(Buf[2]) * 256 + (int)(Buf[3]); - Pref.NLangues = (int)(Buf[4]) * 256 + (int)(Buf[5]); + Pref.NLanguages = (int)(Buf[4]) * 256 + (int)(Buf[5]); - NSprites = NSp + NTextes + Pref.NLangues; + NSprites = NSp + NTextes + Pref.NLanguages; Sprites = new Sprite[NSprites]; // Récupère les nom des langues P = 6; - for (i = 0; i < Pref.NLangues; i++) { + for (i = 0; i < Pref.NLanguages; i++) { strcpy(Langue[i], (char *)(Buf + P)); P += strlen((char *)(Buf + P)) + 1; } // Charge les sprites des langues - for (i = 0; i < Pref.NLangues; i++) { + for (i = 0; i < Pref.NLanguages; i++) { if (Sprites[T_Langue + i].Load(Buf, P) == false) { return false; } diff --git a/src/utils.cc b/src/utils.cc index bc3ffb7..bf0925d 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -280,15 +280,15 @@ bool Utils::LoadPref() } pv = ini.GetValue("easy", "maxLevel"); if (pv) { - Pref.NiveauMax[0] = std::stof(pv); + Pref.LevelMax[0] = std::stof(pv); } pv = ini.GetValue("normal", "maxLevel"); if (pv) { - Pref.NiveauMax[1] = std::stof(pv); + Pref.LevelMax[1] = std::stof(pv); } pv = ini.GetValue("difficult", "maxLevel"); if (pv) { - Pref.NiveauMax[2] = std::stof(pv); + Pref.LevelMax[2] = std::stof(pv); } for (int i = 0; i < 8; ++i) { std::string scoreKey = "score_" + std::to_string(i); @@ -317,9 +317,9 @@ bool Utils::LoadPref() Pref.Volume = oldPref.Volume; Pref.VolumeM = oldPref.VolumeM; // Try to restore max difficulty from the level stored in conf - Pref.NiveauMax[0] = oldPref.Difficulte == Easy ? oldPref.NiveauMax : 0; - Pref.NiveauMax[1] = oldPref.Difficulte == Normal ? oldPref.NiveauMax : 0; - Pref.NiveauMax[2] = oldPref.Difficulte == Hard ? oldPref.NiveauMax : 0; + Pref.LevelMax[0] = oldPref.Difficulte == Easy ? oldPref.NiveauMax : 0; + Pref.LevelMax[1] = oldPref.Difficulte == Normal ? oldPref.NiveauMax : 0; + Pref.LevelMax[2] = oldPref.Difficulte == Hard ? oldPref.NiveauMax : 0; for (int i = 0; i < 8; ++i) { Pref.Sco[i].Score = oldPref.Sco[i].Score; strncpy(Pref.Sco[i].Name, oldPref.Sco[i].Name, 80); @@ -347,9 +347,9 @@ void Utils::SavePref() ini.SetValue("main", "audioVolume", std::to_string(Pref.Volume).c_str()); ini.SetValue("main", "musicVolume", std::to_string(Pref.VolumeM).c_str()); ini.SetValue("main", "humanRightsQuiz", std::to_string(Pref.HumanRightsQuiz).c_str()); - ini.SetValue("easy", "maxLevel", std::to_string(Pref.NiveauMax[0]).c_str()); - ini.SetValue("normal", "maxLevel", std::to_string(Pref.NiveauMax[1]).c_str()); - ini.SetValue("difficult", "maxLevel", std::to_string(Pref.NiveauMax[2]).c_str()); + ini.SetValue("easy", "maxLevel", std::to_string(Pref.LevelMax[0]).c_str()); + ini.SetValue("normal", "maxLevel", std::to_string(Pref.LevelMax[1]).c_str()); + ini.SetValue("difficult", "maxLevel", std::to_string(Pref.LevelMax[2]).c_str()); for (int i = 0; i < 8; ++i) { std::string scoreKey = "score_" + std::to_string(i); std::string nameKey = "name_" + std::to_string(i); From e2c7537fbafcf61b7d506f8de013d063c81fc28e Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Thu, 15 Jan 2026 09:35:32 +0200 Subject: [PATCH 3/9] Fixed some translation moments --- src/loco.cc | 4 ++-- src/main.cc | 8 ++++---- src/preference.h | 8 ++++---- src/utils.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/loco.cc b/src/loco.cc index 2783474..406ec5d 100644 --- a/src/loco.cc +++ b/src/loco.cc @@ -271,7 +271,7 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) Reduit = DureeJeu - 1; } else { - Alonge = DureeJeu + ALONGE_DURATION; + Alonge = DureeJeu + EXTENSION_DURATION; } break; case C_Reduit: // Si réduit la loco @@ -281,7 +281,7 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) Alonge = DureeJeu - 1; } else { - Reduit = DureeJeu + REDUCED_DURATION; + Reduit = DureeJeu + REDUCTION_DURATION; } break; case C_Speed: // Si Vitesse diff --git a/src/main.cc b/src/main.cc index 815fd2a..4562411 100644 --- a/src/main.cc +++ b/src/main.cc @@ -33,7 +33,7 @@ #include #include -#include "config.h" // Done +#include "config.h" #include "preference.h" #include "game.h" #include "gamepad.h" @@ -44,7 +44,7 @@ #include "menu.h" #include "level.h" #include "editor.h" -#include "utils.h" // Done +#include "utils.h" /*** Global variables ***/ /************************/ @@ -55,9 +55,9 @@ char Titre[] = "Li-ri V" VERSION; Sprite *Sprites = nullptr; // Sprites pointer int NSprites = 0; // Number of sprites in memory -Screen Ec; // 2 Video buffer pointer TODO: RENAME +Screen Ec; // 2 Video buffer pointer sNewPreference Pref; // Preference table. -Level level; // Level class +Level level; int currentTime = 0; // Game clock int previousTime = 0; diff --git a/src/preference.h b/src/preference.h index 684b5ce..72a0316 100644 --- a/src/preference.h +++ b/src/preference.h @@ -33,8 +33,8 @@ #define PAUSE_DURATION (3 * 1000) -#define REDUCED_DURATION (10 * 1000) -#define ALONGE_DURATION (10 * 1000) +#define REDUCTION_DURATION (10 * 1000) +#define EXTENSION_DURATION (10 * 1000) #define WAGON_GAP_MAX 27.0 #define WAGON_GAP_AVERAGE 13.0 #define WAGON_GAP_MIN 4.0 @@ -99,7 +99,7 @@ struct sOldPreference struct sScore Sco[8]; // Mémorise les scores }; -struct sNewPreference // Here too +struct sNewPreference { e_Difficulty Difficulty { Normal }; // current game difficulty int Level; // current level @@ -118,7 +118,7 @@ struct sNewPreference // Here too int HumanRightsQuiz { 1 }; // enable the human rights questions at the end of a level }; -enum eMenu { // TODO: Rename +enum eMenu { mMenu, mMenuGame, mMenuSpeed, diff --git a/src/utils.h b/src/utils.h index 0708fc0..fa5411e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -35,8 +35,8 @@ class Utils static void GetPath(char *Path); // Add the path to the filename depending on the OS (sprites, levels) - static bool LoadPref(); // Load preferences - static void SavePref(); // Save preferences + static bool LoadPref(); + static void SavePref(); static void doScreenshot(SDL_Renderer *renderer); }; From d9074cd409fa616bd1800cca483b8c94dbd11fbc Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Thu, 15 Jan 2026 11:01:30 +0200 Subject: [PATCH 4/9] Renamed sprites to english --- src/editor.cc | 18 +++++++-------- src/game.cc | 6 ++--- src/loco.cc | 10 ++++---- src/menu.cc | 64 +++++++++++++++++++++++++-------------------------- src/mouse.cc | 2 +- src/sprite.cc | 14 +++++------ src/sprite.h | 32 +++++++++++++------------- 7 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/editor.cc b/src/editor.cc index f891bd5..992d83b 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -173,10 +173,10 @@ eMenu Editor::SDLMain(int NumNiv) case pluscourt: level.T[NumN].T[cy * LT + cx] = C_Reduit; break; - case vitesse: + case speed: level.T[NumN].T[cy * LT + cx] = C_Speed; break; - case vie: + case life: level.T[NumN].T[cy * LT + cx] = C_Live; break; case (e_Sprite)(locomotive + D_Top): @@ -266,10 +266,10 @@ void Editor::Affiche() const Sprites[pluscourt].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; case C_Speed: // Si plus vite - Sprites[vitesse].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[speed].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; case C_Live: // Si une vie - Sprites[vie].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[life].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; } } @@ -296,8 +296,8 @@ void Editor::Affiche() const case wagon: case pluslong: case pluscourt: - case vitesse: - case vie: + case speed: + case life: Sprites[Option].Affiche(740, 200, 0); break; case (e_Sprite)(locomotive + D_Top): @@ -321,7 +321,7 @@ void Editor::Affiche() const // Affiche le curseur if (Option != deco) { - Sprites[curseur].Affiche(m_mouse.Px, m_mouse.Py, 0); + Sprites[cursor].Affiche(m_mouse.Px, m_mouse.Py, 0); } else { Sprites[deco].Affiche(m_mouse.Px, m_mouse.Py, NumDeco); @@ -427,10 +427,10 @@ void Editor::PrendTouche(int Tou) Option = pluscourt; break; case 't': - Option = vitesse; + Option = speed; break; case 'y': - Option = vie; + Option = life; break; } } diff --git a/src/game.cc b/src/game.cc index 942e31e..8875443 100644 --- a/src/game.cc +++ b/src/game.cc @@ -552,10 +552,10 @@ void Game::AfficheEcran() Ec.PrintSprite(pluscourt, (DureeJeu * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2); break; case C_Speed: // Si plus vite - Ec.PrintSprite(vitesse, (DureeJeu * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2); + Ec.PrintSprite(speed, (DureeJeu * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2); break; case C_Live: // Si une vie - Ec.PrintSprite(vie, (DureeJeu * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2); + Ec.PrintSprite(life, (DureeJeu * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2); break; } } @@ -574,6 +574,6 @@ void Game::AfficheEcran() Ec.PrintSprite(pluslong, (DureeJeu * 40 / 1000) % 50, 715, 295); } if (Pref.SpeedAverage > Pref.Speed) { - Ec.PrintSprite(vitesse, (DureeJeu * 40 / 1000 + 7) % 50, 765, 295); + Ec.PrintSprite(speed, (DureeJeu * 40 / 1000 + 7) % 50, 765, 295); } } diff --git a/src/loco.cc b/src/loco.cc index 406ec5d..eb345c3 100644 --- a/src/loco.cc +++ b/src/loco.cc @@ -103,7 +103,7 @@ void Loco::Init(int Pos, int Direction) // Initialise la loco et son wagon à charbon NWagon = 2; Wagon[0] = locomotive; - Wagon[1] = charbon; + Wagon[1] = coal_wagon; PosWagon[0].SprStart = PosWagon[1].SprStart = N_SPR_START; PosWagon[0].dx = PosWagon[0].dy = -10; PosWagon[0].fx = PosWagon[0].fy = -10; @@ -128,7 +128,7 @@ void Loco::Display(Screen &Ec) for (i = 0; i < NWagon; i++) { // Cherche les points du wagons switch (Wagon[i]) { - case charbon: + case coal_wagon: p1 = ltrain + 11; p2 = ltrain + 36 - 11; ltrain += 36.0; @@ -224,7 +224,7 @@ void Loco::Display(Screen &Ec) if (PosWagon[i].SprStart < N_SPR_START) { PosWagon[i].SprStart += MemoDuree * N_SPR_START / 750.0; if (PosWagon[i].SprStart < N_SPR_START) { - Ec.PrintSprite(nouveau_wagon, (int)(PosWagon[i].SprStart), x1, y1); + Ec.PrintSprite(new_wagon, (int)(PosWagon[i].SprStart), x1, y1); } } @@ -669,10 +669,10 @@ void Loco::FindPoint(float Dist, int &x, int &y) /*********************************/ void Loco::AddLoco() { - Wagon[NWagon] = (e_Sprite)(rand() % (wagon - buches) + buches); + Wagon[NWagon] = (e_Sprite)(rand() % (wagon - logs_wagon) + logs_wagon); if (Wagon[NWagon] == Wagon[NWagon - 1]) { // Evite 2 fois le meme wagon if (Wagon[NWagon] + 1 == wagon) { - Wagon[NWagon] = buches; + Wagon[NWagon] = logs_wagon; } else { Wagon[NWagon] = (e_Sprite)(Wagon[NWagon] + 1); diff --git a/src/menu.cc b/src/menu.cc index a375a7f..18fe857 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -119,7 +119,7 @@ eMenu Menu::SDLMain() // Prend l'image du fond et fait l'affichage Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); Sprites[menu].Affiche(400, 340, 0, Sprites[fmenu].Image[0]); - Sprites[titre].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); + Sprites[title].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); Sprites[copyright].Affiche(400, 587, 0, Sprites[fmenu].Image[0]); AfficheText(400, 229, T_play, Sprites[fmenu].Image[0]); @@ -368,7 +368,7 @@ void Menu::InitMain_Options() Sprites[gmenu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); Sprites[keys].Affiche(610, 455, 0, Sprites[fmenu].Image[0]); - AddBouton(0, bruitage, 140, 110); + AddBouton(0, sound, 140, 110); AddBouton(1, music, 160, 200); AddBouton(2, fscreen, 190, 300); @@ -377,16 +377,16 @@ void Menu::InitMain_Options() Sprites[fscreen].Affiche(185, 300, 0, Sprites[fmenu].Image[0]); Sprites[window].Affiche(625, 300, 0, Sprites[fmenu].Image[0]); - AddBouton(3, monde, 180, 400); + AddBouton(3, earth, 180, 400); // Centre à gauche le text de menu CentreM = 120 + Sprites[T_menu].Dim[0].L / 2; AfficheText(CentreM, 490, T_menu, Sprites[fmenu].Image[0]); AddBouton(4, T_menu, CentreM, 490); - // Boutons des bruitages - Sprites[fleches].Affiche(250, 110, 1, Sprites[fmenu].Image[0]); - Sprites[fleches].Affiche(700, 110, 4, Sprites[fmenu].Image[0]); + // Boutons des sounds + Sprites[arrows].Affiche(250, 110, 1, Sprites[fmenu].Image[0]); + Sprites[arrows].Affiche(700, 110, 4, Sprites[fmenu].Image[0]); Menu_Py[5].DepX = 230; Menu_Py[5].DepY = 70; Menu_Py[5].FinX = 475; @@ -402,8 +402,8 @@ void Menu::InitMain_Options() Menu_Py[6].Valide = true; // Boutons de musics - Sprites[fleches].Affiche(250, 200, 1, Sprites[fmenu].Image[0]); - Sprites[fleches].Affiche(700, 200, 4, Sprites[fmenu].Image[0]); + Sprites[arrows].Affiche(250, 200, 1, Sprites[fmenu].Image[0]); + Sprites[arrows].Affiche(700, 200, 4, Sprites[fmenu].Image[0]); Menu_Py[7].DepX = 230; Menu_Py[7].DepY = 155; Menu_Py[7].FinX = 475; @@ -599,20 +599,20 @@ eMenu Menu::SDLMain_Options() // Ec.Efface(fmenu); if (Pref.FullScreen) { - Ec.PrintSprite(fleches, 1, 350, 300); - Ec.PrintSprite(fleches, 3, 450, 300); + Ec.PrintSprite(arrows, 1, 350, 300); + Ec.PrintSprite(arrows, 3, 450, 300); } else { - Ec.PrintSprite(fleches, 0, 350, 300); - Ec.PrintSprite(fleches, 4, 450, 300); + Ec.PrintSprite(arrows, 0, 350, 300); + Ec.PrintSprite(arrows, 4, 450, 300); } NumSp = (currentTime / 30) % 25; - Ec.PrintSprite(bruitage, NumSp, 150, 110); + Ec.PrintSprite(sound, NumSp, 150, 110); NumSp = (currentTime / 30) % 25; Ec.PrintSprite(music, NumSp, 150, 200); NumSp = (currentTime / 50) % 50; - Ec.PrintSprite(monde, NumSp, 180, 400); + Ec.PrintSprite(earth, NumSp, 180, 400); N = (int)(Pref.Volume * 10 + 1) / SDL_MIX_MAXVOLUME; NumSp = (currentTime / 50) % 40 + 120; @@ -621,7 +621,7 @@ eMenu Menu::SDLMain_Options() Ec.PrintSprite(locomotive, NumSp, (690 - 300) / 10 * i + 300, 110); } else { - Ec.PrintSprite(buches, NumSp, (690 - 300) / 10 * i + 300, 110); + Ec.PrintSprite(logs_wagon, NumSp, (690 - 300) / 10 * i + 300, 110); } } @@ -631,7 +631,7 @@ eMenu Menu::SDLMain_Options() Ec.PrintSprite(locomotive, NumSp, (690 - 300) / 10 * i + 300, 200); } else { - Ec.PrintSprite(buches, NumSp, (690 - 300) / 10 * i + 300, 200); + Ec.PrintSprite(logs_wagon, NumSp, (690 - 300) / 10 * i + 300, 200); } } @@ -691,7 +691,7 @@ eMenu Menu::SDLMain_Speed() // Prend l'image du fond et fait l'affichage Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); Sprites[menu].Affiche(400, 340, 0, Sprites[fmenu].Image[0]); - Sprites[titre].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); + Sprites[title].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); AfficheText(400, 225, T_easy, Sprites[fmenu].Image[0]); AddBouton(0, T_easy, 400, 225); @@ -797,7 +797,7 @@ eMenu Menu::SDLMain_Level() // Prend l'image du fond et fait l'affichage Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); Sprites[menu].Affiche(400, 340, 0, Sprites[fmenu].Image[0]); - Sprites[titre].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); + Sprites[title].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); AfficheText(400, 225, T_new_game, Sprites[fmenu].Image[0]); AddBouton(0, T_new_game, 400, 225); @@ -806,8 +806,8 @@ eMenu Menu::SDLMain_Level() AfficheText(400, 455, T_menu, Sprites[fmenu].Image[0]); AddBouton(2, T_menu, 400, 455); - AddBouton(3, fleches, 330, 380); - AddBouton(4, fleches, 470, 380); + AddBouton(3, arrows, 330, 380); + AddBouton(4, arrows, 470, 380); Menu_Py[5].DepX = -1; @@ -903,26 +903,26 @@ eMenu Menu::SDLMain_Level() // Affiche les flèches if (Niv > 0) { if (PyE == 3) { - Ec.PrintSprite(fleches, 2, 330, 380); + Ec.PrintSprite(arrows, 2, 330, 380); } else { - Ec.PrintSprite(fleches, 1, 330, 380); + Ec.PrintSprite(arrows, 1, 330, 380); } } else { - Ec.PrintSprite(fleches, 0, 330, 380); + Ec.PrintSprite(arrows, 0, 330, 380); } if (Niv < Pref.LevelMax[Pref.Difficulty]) { if (PyE == 4) { - Ec.PrintSprite(fleches, 5, 470, 380); + Ec.PrintSprite(arrows, 5, 470, 380); } else { - Ec.PrintSprite(fleches, 4, 470, 380); + Ec.PrintSprite(arrows, 4, 470, 380); } } else { - Ec.PrintSprite(fleches, 3, 470, 380); + Ec.PrintSprite(arrows, 3, 470, 380); } AfficheChiffre(400, 380, Niv + 1); @@ -1421,8 +1421,8 @@ eMenu Menu::SDLMain_Score(bool EditScore) AfficheString(140, 120 + NEdit * (360 / 7), Pref.Sco[NEdit].Name); i = (currentTime / 50) % 20; // Affiche les curseurs - Ec.PrintSprite(fleche_gauche, i, 110, 120 + NEdit * (360 / 7)); - Ec.PrintSprite(fleche_droite, i, 180 + LongueurString(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); + Ec.PrintSprite(arrow_left, i, 110, 120 + NEdit * (360 / 7)); + Ec.PrintSprite(arrow_right, i, 180 + LongueurString(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); } // Echange les buffets video @@ -1445,8 +1445,8 @@ void Menu::Print_Main(int Centre) const int const x2 = (Centre - x1) + Centre; int const y = (Menu_Py[PyE].FinY + Menu_Py[PyE].DepY) / 2; - Ec.PrintSprite(fleche_gauche, NumSp, x1, y); - Ec.PrintSprite(fleche_droite, NumSp, x2, y); + Ec.PrintSprite(arrow_left, NumSp, x1, y); + Ec.PrintSprite(arrow_right, NumSp, x2, y); } /*** Centre les flèches sur le boutton ***/ @@ -1458,6 +1458,6 @@ void Menu::Affiche_Main_Centre() const int const x2 = Menu_Py[PyE].FinX + 5; int const y = (Menu_Py[PyE].FinY + Menu_Py[PyE].DepY) / 2; - Ec.PrintSprite(fleche_gauche, NumSp, x1, y); - Ec.PrintSprite(fleche_droite, NumSp, x2, y); + Ec.PrintSprite(arrow_left, NumSp, x1, y); + Ec.PrintSprite(arrow_right, NumSp, x2, y); } diff --git a/src/mouse.cc b/src/mouse.cc index 9dff259..c39762f 100644 --- a/src/mouse.cc +++ b/src/mouse.cc @@ -143,6 +143,6 @@ void Mouse::Print() const #ifndef ANDROID // Affiche le curseur - Ec.PrintSprite(curseur, NumSp, X, Y); + Ec.PrintSprite(cursor, NumSp, X, Y); #endif } diff --git a/src/sprite.cc b/src/sprite.cc index b2a1eba..8b2b5e7 100644 --- a/src/sprite.cc +++ b/src/sprite.cc @@ -57,12 +57,12 @@ void AfficheChargeur() if (AfficheC == true) { Hor = SDL_GetTicks(); - i = (Hor / (1000 / 25)) % Sprites[chargeur].N; // Calcule le numéro su sprite à afficher + i = (Hor / (1000 / 25)) % Sprites[digits].N; // Calcule le numéro su sprite à afficher if (i != NumAf) { Old = NumAf; NumAf = i; - Sprites[chargeur].Affiche(400, 300, NumAf); + Sprites[digits].Affiche(400, 300, NumAf); SDL_RenderPresent(sdlRenderer); // TODO if(Old!=-1) Sprites[chargeur].Efface(400,300,Old,sdlVideo); } @@ -159,7 +159,7 @@ bool LoadSprites() } } - if (Sprites[chargeur].Load(Buf, P) == false) { + if (Sprites[digits].Load(Buf, P) == false) { return false; // Sprite du chargeur } AfficheC = true; // Peut afficher le sprite du chargeur @@ -190,7 +190,7 @@ bool LoadSprites() case rope: Sprites[i].N = 0; break; - case chargeur: + case loading: break; default: if (Sprites[i].Load(Buf, P) == false) { @@ -218,7 +218,7 @@ int LongueurChiffre(int C) int l = 0; do { - l += Sprites[chiffres].Dim[(C % 10)].L; + l += Sprites[digits].Dim[(C % 10)].L; C /= 10; if (C) { l += ECART_ENTRE_CHIFFRE; @@ -279,8 +279,8 @@ void AfficheChiffre(int x, int y, int Nombre, SDL_Texture *Fond) x += l / 2; do { - Sprites[chiffres].Affiche(x - (Sprites[chiffres].Dim[(Nombre % 10)].L) / 2, y, Nombre % 10, Fond); - x -= Sprites[chiffres].Dim[(Nombre % 10)].L + ECART_ENTRE_CHIFFRE; + Sprites[digits].Affiche(x - (Sprites[digits].Dim[(Nombre % 10)].L) / 2, y, Nombre % 10, Fond); + x -= Sprites[digits].Dim[(Nombre % 10)].L + ECART_ENTRE_CHIFFRE; Nombre /= 10; } while (Nombre); } diff --git a/src/sprite.h b/src/sprite.h index 9f4e280..80840be 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -45,32 +45,32 @@ struct s_Dim /***********************/ enum e_Sprite { locomotive = 0, - charbon, - buches, + coal_wagon, + logs_wagon, balles, - moteur, - citerne, + engine_wagon, + cistern_wagon, wagon, pluslong, pluscourt, - vitesse, - vie, - nouveau_wagon, + speed, + life, + new_wagon, logo_vie, rail, dir, lettres, - chiffres, - titre, + digits, + title, copyright, deco, - curseur, - fleche_gauche, - fleche_droite, - fleches, - monde, + cursor, + arrow_left, + arrow_right, + arrows, + earth, music, - bruitage, + sound, fscreen, window, keys, @@ -84,7 +84,7 @@ enum e_Sprite { fjeu, fmenu, rope, - chargeur, + loading, T_level, T_lives, From b7e9f6cd18c073fada053aab40bc72fd75843262 Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Thu, 15 Jan 2026 11:04:48 +0200 Subject: [PATCH 5/9] Renamed cargo wagon too --- src/sprite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sprite.h b/src/sprite.h index 80840be..bcb55ed 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -47,7 +47,7 @@ enum e_Sprite { locomotive = 0, coal_wagon, logs_wagon, - balles, + cargo_wagon, engine_wagon, cistern_wagon, wagon, From 331b12c35bbd198749aabdc86cdc705b491a84e1 Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Thu, 15 Jan 2026 19:23:49 +0200 Subject: [PATCH 6/9] More translation fixes --- src/game.cc | 8 ++++---- src/loco.cc | 26 +++++++++++++------------- src/loco.h | 2 +- src/preference.h | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/game.cc b/src/game.cc index 8875443..8a54ffb 100644 --- a/src/game.cc +++ b/src/game.cc @@ -84,7 +84,7 @@ eMenu Game::SDLMain() Key = 0; // Met le options de départ du joueur - Pref.Lifes = N_LIFES_COUNT; + Pref.Lives = N_LIVES_COUNT; Pref.Score = 0; // Prend les evenements @@ -243,7 +243,7 @@ eMenu Game::SDLMain() // Test la fin d'une partie if (Lo.Mort > -1 && Lo.Mort < currentTime) { // Si est Mort test si doit continuer ou quitter - if (Pref.Lifes < 0) { + if (Pref.Lives < 0) { return mScoreEdit; // Si mort fini } if (Lo.Gagne) { @@ -254,7 +254,7 @@ eMenu Game::SDLMain() #endif NumN++; if (level.N == NumN) { - Pref.Score += Pref.Lifes * 100; + Pref.Score += Pref.Lives * 100; return mScoreEdit; } if (Pref.LevelMax[Pref.Difficulty] < NumN) { @@ -566,7 +566,7 @@ void Game::AfficheEcran() } // Affiche tableau de bord - Ec.PrintOptions(Pref.Lifes, Pref.Score); + Ec.PrintOptions(Pref.Lives, Pref.Score); if (Pref.WagonGap < WAGON_GAP_MIN) { Ec.PrintSprite(pluscourt, (DureeJeu * 40 / 1000) % 50, 715, 295); } diff --git a/src/loco.cc b/src/loco.cc index eb345c3..db30b66 100644 --- a/src/loco.cc +++ b/src/loco.cc @@ -58,7 +58,7 @@ void Loco::Init(int Pos, int Direction) PLoco = 0; // Pointe sur la première case PInter = -1; - Vitesse = Reduit = Alonge = 0; // Pas d'alongement + Speed = Reduce = Extend = 0; // Pas d'alongement Mort = -1; Gagne = false; Pref.WagonGap = WAGON_GAP_AVERAGE; @@ -267,33 +267,33 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) m_audio.Play(sEtire); Tableau[T[PLoco].P] = 1; // efface l'option Pref.Score += 20; - if (Reduit > DureeJeu) { - Reduit = DureeJeu - 1; + if (Reduce > DureeJeu) { + Reduce = DureeJeu - 1; } else { - Alonge = DureeJeu + EXTENSION_DURATION; + Extend = DureeJeu + EXTENSION_DURATION; } break; case C_Reduit: // Si réduit la loco m_audio.Play(sReduit); Tableau[T[PLoco].P] = 1; // efface l'option - if (Alonge > DureeJeu) { - Alonge = DureeJeu - 1; + if (Extend > DureeJeu) { + Extend = DureeJeu - 1; } else { - Reduit = DureeJeu + REDUCTION_DURATION; + Reduce = DureeJeu + REDUCTION_DURATION; } break; case C_Speed: // Si Vitesse m_audio.Play(sSpeed); Tableau[T[PLoco].P] = 1; // efface l'option Pref.Score += 30; - Vitesse = DureeJeu + SPEED_DURATION; + Speed = DureeJeu + SPEED_DURATION; break; case C_Live: // Si Vie m_audio.Play(sLive); Tableau[T[PLoco].P] = 1; // efface l'option - Pref.Lifes++; + Pref.Lives++; break; } @@ -309,7 +309,7 @@ void Loco::TestCase(float Dist, long DureeJeu, int *Tableau) // Si colition le signale if (Mort < currentTime && (Ec1 < RAYON_TOUCHE || Ec2 <= RAYON_TOUCHE)) { m_audio.Play(sCrash); - Pref.Lifes--; + Pref.Lives--; Mort = currentTime + PAUSE_DURATION; } } @@ -328,7 +328,7 @@ void Loco::Avance(int Duree, long DureeJeu, int *Touche, int *Tableau) TestCase(Dist, DureeJeu, Tableau); // Test si doit Réduire le wagon - if (Reduit > DureeJeu) { + if (Reduce > DureeJeu) { if (Pref.WagonGap > WAGON_GAP_MIN) { // Si doit réduire Pref.WagonGap -= (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon - 1)) / 1000.0; if (Pref.WagonGap < WAGON_GAP_MIN) { @@ -346,7 +346,7 @@ void Loco::Avance(int Duree, long DureeJeu, int *Touche, int *Tableau) } // Test si doit Ralonger le wagon - if (Alonge > DureeJeu) { + if (Extend > DureeJeu) { if (Pref.WagonGap < WAGON_GAP_MAX) { // Si doit Ralonger Pref.WagonGap += (float)(Duree) * (Pref.SpeedAverage * 0.8 / (float)(NWagon)) / 1000.0; if (Pref.WagonGap > WAGON_GAP_MAX) { @@ -364,7 +364,7 @@ void Loco::Avance(int Duree, long DureeJeu, int *Touche, int *Tableau) } // Test si doit modifier la vitesse de la loco - if (Vitesse > DureeJeu) { + if (Speed > DureeJeu) { if (Pref.SpeedAverage < Pref.Speed * 2) { // Si doit accelerer Pref.SpeedAverage += (float)(Duree) / 40.0; if (Pref.SpeedAverage > Pref.Speed * 2) { diff --git a/src/loco.h b/src/loco.h index 6160615..302a78e 100644 --- a/src/loco.h +++ b/src/loco.h @@ -74,7 +74,7 @@ class Loco private: /*** Variables ***/ - long Reduit, Alonge, Vitesse; // Memorise l'horloge de fin si doit réduire ou alonger le train + long Reduce, Extend, Speed; // Memorise l'horloge de fin si doit réduire ou alonger le train int PLoco; // Position de la tête de la loco dans le tableau float D; // Distance parcourue par la loco struct s_TLoco T[256]; // Mémorise le parcour de la loco maxi = 256 cases diff --git a/src/preference.h b/src/preference.h index 72a0316..b24bdef 100644 --- a/src/preference.h +++ b/src/preference.h @@ -39,7 +39,7 @@ #define WAGON_GAP_AVERAGE 13.0 #define WAGON_GAP_MIN 4.0 -#define N_LIFES_COUNT 3 +#define N_LIVES_COUNT 3 #define RAYON_TOUCHE (32 * 32) @@ -85,7 +85,7 @@ struct sOldPreference { e_Difficulty Difficulte; // Difficulté de la partie (Vitesse) int Level; // Niveau du joueur - int Lifes; // Nombre de vie du joueur + int Lives; // Nombre de vie du joueur int Score; // Score du joueur double Vitesse; // Vitesse suivant le niveau double VitesseMoy; // Vitesse en cours de la loco @@ -103,7 +103,7 @@ struct sNewPreference { e_Difficulty Difficulty { Normal }; // current game difficulty int Level; // current level - int Lifes { N_LIFES_COUNT }; // current number of life + int Lives { N_LIVES_COUNT }; // current number of life int Score; // current score double Speed { SPEED_AVERAGE }; // speed ​​depending on level double SpeedAverage { SPEED_AVERAGE }; // current speed of the locomotive From f2847078c7529a990d2208081fce86bf57fe3f32 Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Fri, 16 Jan 2026 15:22:49 +0200 Subject: [PATCH 7/9] Fixed critical bug with loading animation --- src/audio.cc | 4 ++-- src/audio.h | 2 +- src/sprite.cc | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/audio.cc b/src/audio.cc index f59d972..7663d33 100644 --- a/src/audio.cc +++ b/src/audio.cc @@ -162,10 +162,10 @@ void Audio::Play(eSon So) } if (So == sClic) { - if (currentTime - MemoHorloge <= 120) { + if (currentTime - MemorizedTime <= 120) { return; } - MemoHorloge = currentTime; + MemorizedTime = currentTime; } Mix_PlayChannel(-1, Son[So], 0); diff --git a/src/audio.h b/src/audio.h index 4823562..40f1bb1 100644 --- a/src/audio.h +++ b/src/audio.h @@ -66,7 +66,7 @@ class Audio /*** Variables ***/ int N { 0 }; // Nombre d'échantillon audio int NMus { 0 }; // Numéro de la music en cours - int MemoHorloge { 0 }; // Mémorise l'horloge pour les clics + int MemorizedTime { 0 }; // Mémorise l'horloge pour les clics Mix_Chunk **Son { nullptr }; // Pointe sur les sons }; diff --git a/src/sprite.cc b/src/sprite.cc index 8b2b5e7..4b413da 100644 --- a/src/sprite.cc +++ b/src/sprite.cc @@ -57,12 +57,12 @@ void AfficheChargeur() if (AfficheC == true) { Hor = SDL_GetTicks(); - i = (Hor / (1000 / 25)) % Sprites[digits].N; // Calcule le numéro su sprite à afficher + i = (Hor / (1000 / 25)) % Sprites[loading].N; // Calcule le numéro su sprite à afficher if (i != NumAf) { Old = NumAf; NumAf = i; - Sprites[digits].Affiche(400, 300, NumAf); + Sprites[loading].Affiche(400, 300, NumAf); SDL_RenderPresent(sdlRenderer); // TODO if(Old!=-1) Sprites[chargeur].Efface(400,300,Old,sdlVideo); } @@ -159,7 +159,7 @@ bool LoadSprites() } } - if (Sprites[digits].Load(Buf, P) == false) { + if (Sprites[loading].Load(Buf, P) == false) { return false; // Sprite du chargeur } AfficheC = true; // Peut afficher le sprite du chargeur From 164583c2be7a18ff8d2f6e25842f50b6b37bb4b1 Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Fri, 16 Jan 2026 16:27:35 +0200 Subject: [PATCH 8/9] Renamed GFX stuff in code (Like draw functions) --- src/editor.cc | 52 ++++++------ src/editor.h | 2 +- src/game.cc | 16 ++-- src/main.cc | 2 +- src/menu.cc | 228 +++++++++++++++++++++++++------------------------- src/screen.cc | 10 +-- src/sprite.cc | 52 ++++++------ src/sprite.h | 20 ++--- src/utils.cc | 2 +- 9 files changed, 192 insertions(+), 192 deletions(-) diff --git a/src/editor.cc b/src/editor.cc index 992d83b..eaf7cd8 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -62,7 +62,7 @@ eMenu Editor::SDLMain(int NumNiv) NumN = NumNiv; - Affiche(); // Charge le tableau + Draw(); // Charge le tableau SDL_RenderPresent(sdlRenderer); currentTime = SDL_GetTicks(); // Prend l'horloge @@ -82,7 +82,7 @@ eMenu Editor::SDLMain(int NumNiv) switch (event.type) { case SDL_WINDOWEVENT: if (event.window.event == SDL_WINDOWEVENT_ENTER) { - Affiche(); + Draw(); } break; case SDL_KEYDOWN: @@ -198,7 +198,7 @@ eMenu Editor::SDLMain(int NumNiv) Sleeping(); // Fait l'affichage - Affiche(); + Draw(); SDL_RenderPresent(sdlRenderer); } while (true); @@ -208,7 +208,7 @@ eMenu Editor::SDLMain(int NumNiv) /*** Charge un tableau ***/ /*************************/ -void Editor::Affiche() const +void Editor::Draw() const { int i, x, y, m, cx, cy; unsigned char *T; @@ -217,7 +217,7 @@ void Editor::Affiche() const T = level.T[NumN].T; // Fabrique le fond du jeu - Sprites[fond].Affiche(400, 300, 0); + Sprites[fond].Draw(400, 300, 0); // Affiche le circuit for (i = 0; i < LT * HT; i++) { @@ -241,35 +241,35 @@ void Editor::Affiche() const m += 1; } - Sprites[rail].Affiche(x, y, NumRail[m]); + Sprites[rail].Draw(x, y, NumRail[m]); } } // Affiche les décorations for (i = 0; i < level.T[NumN].NDeco; i++) { - Sprites[deco].Affiche(level.T[NumN].Deco[i].x, level.T[NumN].Deco[i].y, level.T[NumN].Deco[i].NumSpr); + Sprites[deco].Draw(level.T[NumN].Deco[i].x, level.T[NumN].Deco[i].y, level.T[NumN].Deco[i].NumSpr); } // Affiche numero du niveau - AfficheChiffre(740, 130, NumN + 1); + DrawNumber(740, 130, NumN + 1); // Affiche les options for (i = 0; i < LT * HT; i++) { switch (T[i]) { case C_Wagon: // Si un loco - Sprites[wagon].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[wagon].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; case C_Allonge: // Si plus long - Sprites[pluslong].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[pluslong].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; case C_Reduit: // Si plus court - Sprites[pluscourt].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[pluscourt].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; case C_Speed: // Si plus vite - Sprites[speed].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[speed].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; case C_Live: // Si une vie - Sprites[life].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); + Sprites[life].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25); break; } } @@ -277,16 +277,16 @@ void Editor::Affiche() const // Affiche le départ de la locomotive switch (level.T[NumN].DepDir) { case D_Top: - Sprites[locomotive].Affiche(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 0); + Sprites[locomotive].Draw(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 0); break; case D_Bottom: - Sprites[locomotive].Affiche(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 40); + Sprites[locomotive].Draw(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 40); break; case D_Left: - Sprites[locomotive].Affiche(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 80); + Sprites[locomotive].Draw(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 80); break; case D_Right: - Sprites[locomotive].Affiche(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 120); + Sprites[locomotive].Draw(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 120); break; } @@ -298,22 +298,22 @@ void Editor::Affiche() const case pluscourt: case speed: case life: - Sprites[Option].Affiche(740, 200, 0); + Sprites[Option].Draw(740, 200, 0); break; case (e_Sprite)(locomotive + D_Top): - Sprites[locomotive].Affiche(740, 200, 0); + Sprites[locomotive].Draw(740, 200, 0); break; case (e_Sprite)(locomotive + D_Bottom): - Sprites[locomotive].Affiche(740, 200, 40); + Sprites[locomotive].Draw(740, 200, 40); break; case (e_Sprite)(locomotive + D_Left): - Sprites[locomotive].Affiche(740, 200, 80); + Sprites[locomotive].Draw(740, 200, 80); break; case (e_Sprite)(locomotive + D_Right): - Sprites[locomotive].Affiche(740, 200, 120); + Sprites[locomotive].Draw(740, 200, 120); break; case deco: - Sprites[deco].Affiche(740, 200, NumDeco); + Sprites[deco].Draw(740, 200, NumDeco); break; default: break; @@ -321,10 +321,10 @@ void Editor::Affiche() const // Affiche le curseur if (Option != deco) { - Sprites[cursor].Affiche(m_mouse.Px, m_mouse.Py, 0); + Sprites[cursor].Draw(m_mouse.Px, m_mouse.Py, 0); } else { - Sprites[deco].Affiche(m_mouse.Px, m_mouse.Py, NumDeco); + Sprites[deco].Draw(m_mouse.Px, m_mouse.Py, NumDeco); } } @@ -412,7 +412,7 @@ void Editor::PrendTouche(int Tou) Pref.Level = NumN; m_game.SDLMain(); m_mouse.Init(nullptr); - Affiche(); + Draw(); break; case 'a': Option = rail; diff --git a/src/editor.h b/src/editor.h index 7b260bf..f305e3c 100644 --- a/src/editor.h +++ b/src/editor.h @@ -43,7 +43,7 @@ class Editor /*** Fonctions ***/ /*****************/ eMenu SDLMain(int NumNiveau); // Boucle principale - void Affiche() const; // Charge un tableau + void Draw() const; // Charge un tableau void PrendTouche(int Touche); // Prend les touches enfoncées private: diff --git a/src/game.cc b/src/game.cc index 8a54ffb..e06d959 100644 --- a/src/game.cc +++ b/src/game.cc @@ -332,7 +332,7 @@ bool Game::DrawLevel(int NivN) int i, x, y, m, cx, cy; // Fabrique le fond du jeu - Sprites[fond].Affiche(400, 300, 0, Sprites[fjeu].Image[0]); + Sprites[fond].Draw(400, 300, 0, Sprites[fjeu].Image[0]); // Affiche le circuit for (i = 0; i < LT * HT; i++) { @@ -356,25 +356,25 @@ bool Game::DrawLevel(int NivN) m += 1; } - Sprites[rail].Affiche(x, y, NumRail[m], Sprites[fjeu].Image[0]); + Sprites[rail].Draw(x, y, NumRail[m], Sprites[fjeu].Image[0]); } } // Affiche les décorations #ifndef DCHILDREN for (i = 0; i < level.T[NivN].NDeco; i++) { - Sprites[deco].Affiche(level.T[NivN].Deco[i].x, level.T[NivN].Deco[i].y, level.T[NivN].Deco[i].NumSpr, + Sprites[deco].Draw(level.T[NivN].Deco[i].x, level.T[NivN].Deco[i].y, level.T[NivN].Deco[i].NumSpr, Sprites[fjeu].Image[0]); } #endif // Affiche les textes suivant la langue - AfficheText(740, 110, T_level, Sprites[fjeu].Image[0]); - AfficheText(740, 180, T_score, Sprites[fjeu].Image[0]); - AfficheText(740, 260, T_options, Sprites[fjeu].Image[0]); - AfficheText(740, 340, T_lives, Sprites[fjeu].Image[0]); + DrawText(740, 110, T_level, Sprites[fjeu].Image[0]); + DrawText(740, 180, T_score, Sprites[fjeu].Image[0]); + DrawText(740, 260, T_options, Sprites[fjeu].Image[0]); + DrawText(740, 340, T_lives, Sprites[fjeu].Image[0]); - AfficheChiffre(740, 140, Pref.Level + 1, Sprites[fjeu].Image[0]); + DrawNumber(740, 140, Pref.Level + 1, Sprites[fjeu].Image[0]); return true; } diff --git a/src/main.cc b/src/main.cc index 4562411..054bc14 100644 --- a/src/main.cc +++ b/src/main.cc @@ -147,7 +147,7 @@ int main(int narg, char *argv[]) // ask locale if first run if (Pref.Language == -1) { RetMenu = MainMenu.SDLMain_Language(); - LoadLangue(); + LoadLanguage(); } // menu switch diff --git a/src/menu.cc b/src/menu.cc index 18fe857..776d13e 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -77,7 +77,7 @@ void Sleeping() /*** Ajoute une entrée dans le tableau des boutons ***/ /*****************************************************/ -void AddBouton(int Num, e_Sprite NumSp, int X, int Y) +void AddButton(int Num, e_Sprite NumSp, int X, int Y) { int const NumS = (int)NumSp; @@ -117,19 +117,19 @@ eMenu Menu::SDLMain() do { SDL_RenderClear(sdlRenderer); // Prend l'image du fond et fait l'affichage - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); - Sprites[menu].Affiche(400, 340, 0, Sprites[fmenu].Image[0]); - Sprites[title].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); - Sprites[copyright].Affiche(400, 587, 0, Sprites[fmenu].Image[0]); - - AfficheText(400, 229, T_play, Sprites[fmenu].Image[0]); - AddBouton(0, T_play, 400, 229); - AfficheText(400, 306, T_scores, Sprites[fmenu].Image[0]); - AddBouton(1, T_scores, 400, 306); - AfficheText(400, 384, T_moptions, Sprites[fmenu].Image[0]); - AddBouton(2, T_moptions, 400, 384); - AfficheText(400, 461, T_quit, Sprites[fmenu].Image[0]); - AddBouton(3, T_quit, 400, 461); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[menu].Draw(400, 340, 0, Sprites[fmenu].Image[0]); + Sprites[title].Draw(400, 65, 0, Sprites[fmenu].Image[0]); + Sprites[copyright].Draw(400, 587, 0, Sprites[fmenu].Image[0]); + + DrawText(400, 229, T_play, Sprites[fmenu].Image[0]); + AddButton(0, T_play, 400, 229); + DrawText(400, 306, T_scores, Sprites[fmenu].Image[0]); + AddButton(1, T_scores, 400, 306); + DrawText(400, 384, T_moptions, Sprites[fmenu].Image[0]); + AddButton(2, T_moptions, 400, 384); + DrawText(400, 461, T_quit, Sprites[fmenu].Image[0]); + AddButton(3, T_quit, 400, 461); Menu_Py[4].DepX = -1; SDL_Event event; while (SDL_PollEvent(&event)) { @@ -176,7 +176,7 @@ eMenu Menu::SDLMain() break; default: key = event.key.keysym.sym & 0x7F; // Prend le caracataire correspondant à la touche - if (CharExiste(key) == true) { // Si la caractaire existe bien + if (CharExist(key) == true) { // Si la caractaire existe bien for (i = 2; i >= 0; i--) { MCode[i + 1] = MCode[i]; // décale le code } @@ -232,9 +232,9 @@ eMenu Menu::SDLMain_Language() SDL_RenderClear(sdlRenderer); // Prend l'image du fond et fait l'affichage - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); - // Affiche les langues possibles + // Draw les langues possibles NCol = 3; if (Pref.NLanguages % NCol == 0) { NL = Pref.NLanguages / NCol; @@ -248,8 +248,8 @@ eMenu Menu::SDLMain_Language() x = (i / NL) * (800 / 3) + (800 / 6); y = (i % NL) * Ecart + Ecart; - Sprites[T_Langue + i].Affiche(x, y, 0, Sprites[fmenu].Image[0]); - AddBouton(i, (e_Sprite)(T_Langue + i), x, y); + Sprites[T_Langue + i].Draw(x, y, 0, Sprites[fmenu].Image[0]); + AddButton(i, (e_Sprite)(T_Langue + i), x, y); } Menu_Py[Pref.NLanguages].DepX = -1; @@ -260,13 +260,13 @@ eMenu Menu::SDLMain_Language() // Prend les evenements do { SDL_RenderClear(sdlRenderer); - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); for (i = 0; i < Pref.NLanguages; i++) { x = (i / NL) * (800 / 3) + (800 / 6); y = (i % NL) * Ecart + Ecart; - Sprites[T_Langue + i].Affiche(x, y, 0, Sprites[fmenu].Image[0]); - AddBouton(i, (e_Sprite)(T_Langue + i), x, y); + Sprites[T_Langue + i].Draw(x, y, 0, Sprites[fmenu].Image[0]); + AddButton(i, (e_Sprite)(T_Langue + i), x, y); } SDL_Event event; @@ -322,7 +322,7 @@ eMenu Menu::SDLMain_Language() case SDLK_KP_ENTER: Pref.Language = PyE; if (Pref.Language != OldLangue) { - LoadLangue(); + LoadLanguage(); } return mMenu; default: @@ -364,29 +364,29 @@ void Menu::InitMain_Options() // PyE=4; // Prend l'image du fond et fait l'affichage - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); - Sprites[gmenu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); - Sprites[keys].Affiche(610, 455, 0, Sprites[fmenu].Image[0]); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[gmenu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[keys].Draw(610, 455, 0, Sprites[fmenu].Image[0]); - AddBouton(0, sound, 140, 110); - AddBouton(1, music, 160, 200); + AddButton(0, sound, 140, 110); + AddButton(1, music, 160, 200); - AddBouton(2, fscreen, 190, 300); + AddButton(2, fscreen, 190, 300); Menu_Py[2].DepX -= 40; Menu_Py[2].FinX = 625 + 40 + Sprites[fscreen].Dim[0].L / 2; - Sprites[fscreen].Affiche(185, 300, 0, Sprites[fmenu].Image[0]); - Sprites[window].Affiche(625, 300, 0, Sprites[fmenu].Image[0]); + Sprites[fscreen].Draw(185, 300, 0, Sprites[fmenu].Image[0]); + Sprites[window].Draw(625, 300, 0, Sprites[fmenu].Image[0]); - AddBouton(3, earth, 180, 400); + AddButton(3, earth, 180, 400); // Centre à gauche le text de menu CentreM = 120 + Sprites[T_menu].Dim[0].L / 2; - AfficheText(CentreM, 490, T_menu, Sprites[fmenu].Image[0]); - AddBouton(4, T_menu, CentreM, 490); + DrawText(CentreM, 490, T_menu, Sprites[fmenu].Image[0]); + AddButton(4, T_menu, CentreM, 490); // Boutons des sounds - Sprites[arrows].Affiche(250, 110, 1, Sprites[fmenu].Image[0]); - Sprites[arrows].Affiche(700, 110, 4, Sprites[fmenu].Image[0]); + Sprites[arrows].Draw(250, 110, 1, Sprites[fmenu].Image[0]); + Sprites[arrows].Draw(700, 110, 4, Sprites[fmenu].Image[0]); Menu_Py[5].DepX = 230; Menu_Py[5].DepY = 70; Menu_Py[5].FinX = 475; @@ -402,8 +402,8 @@ void Menu::InitMain_Options() Menu_Py[6].Valide = true; // Boutons de musics - Sprites[arrows].Affiche(250, 200, 1, Sprites[fmenu].Image[0]); - Sprites[arrows].Affiche(700, 200, 4, Sprites[fmenu].Image[0]); + Sprites[arrows].Draw(250, 200, 1, Sprites[fmenu].Image[0]); + Sprites[arrows].Draw(700, 200, 4, Sprites[fmenu].Image[0]); Menu_Py[7].DepX = 230; Menu_Py[7].DepY = 155; Menu_Py[7].FinX = 475; @@ -689,16 +689,16 @@ eMenu Menu::SDLMain_Speed() Ec.CleanSpriteAndScreen(fmenu); SDL_RenderClear(sdlRenderer); // Prend l'image du fond et fait l'affichage - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); - Sprites[menu].Affiche(400, 340, 0, Sprites[fmenu].Image[0]); - Sprites[title].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); - - AfficheText(400, 225, T_easy, Sprites[fmenu].Image[0]); - AddBouton(0, T_easy, 400, 225); - AfficheText(400, 340, T_normal, Sprites[fmenu].Image[0]); - AddBouton(1, T_normal, 400, 340); - AfficheText(400, 455, T_hard, Sprites[fmenu].Image[0]); - AddBouton(2, T_hard, 400, 455); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[menu].Draw(400, 340, 0, Sprites[fmenu].Image[0]); + Sprites[title].Draw(400, 65, 0, Sprites[fmenu].Image[0]); + + DrawText(400, 225, T_easy, Sprites[fmenu].Image[0]); + AddButton(0, T_easy, 400, 225); + DrawText(400, 340, T_normal, Sprites[fmenu].Image[0]); + AddButton(1, T_normal, 400, 340); + DrawText(400, 455, T_hard, Sprites[fmenu].Image[0]); + AddButton(2, T_hard, 400, 455); Menu_Py[3].DepX = -1; SDL_Event event; @@ -795,19 +795,19 @@ eMenu Menu::SDLMain_Level() // Efface le fond SDL_RenderClear(sdlRenderer); // Prend l'image du fond et fait l'affichage - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); - Sprites[menu].Affiche(400, 340, 0, Sprites[fmenu].Image[0]); - Sprites[title].Affiche(400, 65, 0, Sprites[fmenu].Image[0]); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[menu].Draw(400, 340, 0, Sprites[fmenu].Image[0]); + Sprites[title].Draw(400, 65, 0, Sprites[fmenu].Image[0]); - AfficheText(400, 225, T_new_game, Sprites[fmenu].Image[0]); - AddBouton(0, T_new_game, 400, 225); - AfficheText(400, 320, T_old_level, Sprites[fmenu].Image[0]); - AddBouton(1, T_old_level, 400, 320); - AfficheText(400, 455, T_menu, Sprites[fmenu].Image[0]); - AddBouton(2, T_menu, 400, 455); + DrawText(400, 225, T_new_game, Sprites[fmenu].Image[0]); + AddButton(0, T_new_game, 400, 225); + DrawText(400, 320, T_old_level, Sprites[fmenu].Image[0]); + AddButton(1, T_old_level, 400, 320); + DrawText(400, 455, T_menu, Sprites[fmenu].Image[0]); + AddButton(2, T_menu, 400, 455); - AddBouton(3, arrows, 330, 380); - AddBouton(4, arrows, 470, 380); + AddButton(3, arrows, 330, 380); + AddButton(4, arrows, 470, 380); Menu_Py[5].DepX = -1; @@ -900,7 +900,7 @@ eMenu Menu::SDLMain_Level() // Gère l'Affichage Ec.ClearSprite(fmenu); - // Affiche les flèches + // Draw les flèches if (Niv > 0) { if (PyE == 3) { Ec.PrintSprite(arrows, 2, 330, 380); @@ -925,7 +925,7 @@ eMenu Menu::SDLMain_Level() Ec.PrintSprite(arrows, 3, 470, 380); } - AfficheChiffre(400, 380, Niv + 1); + DrawNumber(400, 380, Niv + 1); if (PyE != 3 && PyE != 4) { Print_Main(); @@ -966,25 +966,25 @@ eMenu Menu::SDLMain_HR() Position.h = Sprites[fmenu].Dim[0].H; SDL_RenderCopy(sdlRenderer, Sprites[fmenu].Image[0], &Position, &Position); - Sprites[menu].Affiche(340, 300, 0, Sprites[fmenu].Image[0]); - Sprites[fond_hr].Affiche(340, 74, 0, Sprites[fmenu].Image[0]); - AfficheText(338, 70, e_Sprite(T_question), Sprites[fmenu].Image[0]); + Sprites[menu].Draw(340, 300, 0, Sprites[fmenu].Image[0]); + Sprites[fond_hr].Draw(340, 74, 0, Sprites[fmenu].Image[0]); + DrawText(338, 70, e_Sprite(T_question), Sprites[fmenu].Image[0]); - Sprites[locomotive].Affiche(115, 110, rand() % 320, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(100, 160 + (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(100, 470 - (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(580, 100 + (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(580, 470 - (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); + Sprites[locomotive].Draw(115, 110, rand() % 320, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(100, 160 + (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(100, 470 - (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(580, 100 + (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(580, 470 - (rand() % 130), rand() % 18, Sprites[fmenu].Image[0]); - AfficheText(340, 300, e_Sprite(T_art1 + N1), Sprites[fmenu].Image[0]); + DrawText(340, 300, e_Sprite(T_art1 + N1), Sprites[fmenu].Image[0]); if (Ordre) { - AddBouton(0, e_Sprite(T_tart1 + N1), 240, 492); - AddBouton(1, e_Sprite(T_tart1 + N2), 440, 492); + AddButton(0, e_Sprite(T_tart1 + N1), 240, 492); + AddButton(1, e_Sprite(T_tart1 + N2), 440, 492); } else { - AddBouton(0, e_Sprite(T_tart1 + N1), 440, 492); - AddBouton(1, e_Sprite(T_tart1 + N2), 240, 492); + AddButton(0, e_Sprite(T_tart1 + N1), 440, 492); + AddButton(1, e_Sprite(T_tart1 + N2), 240, 492); } Menu_Py[0].DepY -= 20; Menu_Py[0].FinY += 20; @@ -1003,26 +1003,26 @@ eMenu Menu::SDLMain_HR() SDL_RenderCopy(sdlRenderer, Sprites[fmenu].Image[0], &Position, &Position); - // Sprites[fond].Affiche(400,300,0,Sprites[fjeu].Image[0]); - Sprites[menu].Affiche(340, 300, 0, Sprites[fmenu].Image[0]); - Sprites[fond_hr].Affiche(340, 74, 0, Sprites[fmenu].Image[0]); - AfficheText(338, 70, e_Sprite(T_question), Sprites[fmenu].Image[0]); + // Sprites[fond].Draw(400,300,0,Sprites[fjeu].Image[0]); + Sprites[menu].Draw(340, 300, 0, Sprites[fmenu].Image[0]); + Sprites[fond_hr].Draw(340, 74, 0, Sprites[fmenu].Image[0]); + DrawText(338, 70, e_Sprite(T_question), Sprites[fmenu].Image[0]); - Sprites[locomotive].Affiche(115, 110, locoPosition, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(100, 160 + posDeco[0].first, posDeco[0].second, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(100, 470 - (posDeco[1].first), posDeco[1].second, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(580, 100 + (posDeco[2].first), posDeco[2].second, Sprites[fmenu].Image[0]); - Sprites[deco].Affiche(580, 470 - (posDeco[3].first), posDeco[3].second, Sprites[fmenu].Image[0]); + Sprites[locomotive].Draw(115, 110, locoPosition, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(100, 160 + posDeco[0].first, posDeco[0].second, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(100, 470 - (posDeco[1].first), posDeco[1].second, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(580, 100 + (posDeco[2].first), posDeco[2].second, Sprites[fmenu].Image[0]); + Sprites[deco].Draw(580, 470 - (posDeco[3].first), posDeco[3].second, Sprites[fmenu].Image[0]); - AfficheText(340, 300, e_Sprite(T_art1 + N1), Sprites[fmenu].Image[0]); + DrawText(340, 300, e_Sprite(T_art1 + N1), Sprites[fmenu].Image[0]); /* if(Ordre) { - AddBouton(0,e_Sprite(T_tart1+N1),240,492); - AddBouton(1,e_Sprite(T_tart1+N2),440,492); + AddButton(0,e_Sprite(T_tart1+N1),240,492); + AddButton(1,e_Sprite(T_tart1+N2),440,492); } else { - AddBouton(0,e_Sprite(T_tart1+N1),440,492); - AddBouton(1,e_Sprite(T_tart1+N2),240,492); + AddButton(0,e_Sprite(T_tart1+N1),440,492); + AddButton(1,e_Sprite(T_tart1+N2),240,492); } Menu_Py[0].DepY-=20; Menu_Py[0].FinY+=20; @@ -1122,17 +1122,17 @@ eMenu Menu::SDLMain_HR() if (Ordre) { Ec.PrintSprite(fond_hrr, 0, 240, 492); - AfficheText(240, 492, e_Sprite(T_tart1 + N1)); + DrawText(240, 492, e_Sprite(T_tart1 + N1)); } else { Ec.PrintSprite(fond_hrr, 0, 440, 492); - AfficheText(440, 492, e_Sprite(T_tart1 + N1)); + DrawText(440, 492, e_Sprite(T_tart1 + N1)); } if (Fini == -1) { if (Ordre) { Ec.PrintSprite(fond_hrr, 0, 440, 492); - AfficheText(440, 492, e_Sprite(T_tart1 + N2)); + DrawText(440, 492, e_Sprite(T_tart1 + N2)); if (PyE == 0) { Print_Main(240); } @@ -1142,7 +1142,7 @@ eMenu Menu::SDLMain_HR() } else { Ec.PrintSprite(fond_hrr, 0, 240, 492); - AfficheText(240, 492, e_Sprite(T_tart1 + N2)); + DrawText(240, 492, e_Sprite(T_tart1 + N2)); if (PyE == 1) { Print_Main(240); } @@ -1178,14 +1178,14 @@ void Menu::Print_InGame() Position.h = Sprites[fmenu].Dim[0].H; SDL_RenderCopy(sdlRenderer, Sprites[fmenu].Image[0], &Position, &Position); - Sprites[menu].Affiche(340, 300, 0, Sprites[fmenu].Image[0]); + Sprites[menu].Draw(340, 300, 0, Sprites[fmenu].Image[0]); - AfficheText(340, 185, T_continue, Sprites[fmenu].Image[0]); - AddBouton(0, T_continue, 340, 185); - AfficheText(340, 300, T_moptions, Sprites[fmenu].Image[0]); - AddBouton(1, T_moptions, 340, 300); - AfficheText(340, 415, T_exit_game, Sprites[fmenu].Image[0]); - AddBouton(2, T_exit_game, 340, 415); + DrawText(340, 185, T_continue, Sprites[fmenu].Image[0]); + AddButton(0, T_continue, 340, 185); + DrawText(340, 300, T_moptions, Sprites[fmenu].Image[0]); + AddButton(1, T_moptions, 340, 300); + DrawText(340, 415, T_exit_game, Sprites[fmenu].Image[0]); + AddButton(2, T_exit_game, 340, 415); Menu_Py[3].DepX = -1; } @@ -1331,28 +1331,28 @@ eMenu Menu::SDLMain_Score(bool EditScore) Ec.CleanSpriteAndScreen(fmenu); SDL_RenderClear(sdlRenderer); // Prend l'image du fond et fait l'affichage - Sprites[fond_menu].Affiche(400, 300, 0, Sprites[fmenu].Image[0]); + Sprites[fond_menu].Draw(400, 300, 0, Sprites[fmenu].Image[0]); - // Affiche le titre et les commandes - AfficheText(400, 50, T_better_scores, Sprites[fmenu].Image[0]); - AfficheText(400, 550, T_press_any_key, Sprites[fmenu].Image[0]); + // Draw le titre et les commandes + DrawText(400, 50, T_better_scores, Sprites[fmenu].Image[0]); + DrawText(400, 550, T_press_any_key, Sprites[fmenu].Image[0]); - // Affiche les scores + // Draw les scores for (i = 0; i < 8; i++) { sprintf(Provi, "%d", i + 1); - AfficheString(70, 120 + i * (360 / 7), Provi, Sprites[fmenu].Image[0]); + DrawString(70, 120 + i * (360 / 7), Provi, Sprites[fmenu].Image[0]); if (EditScore == false || NEdit != i) { if (Pref.Sco[i].Name[0]) { - AfficheString(140, 120 + i * (360 / 7), Pref.Sco[i].Name, Sprites[fmenu].Image[0]); + DrawString(140, 120 + i * (360 / 7), Pref.Sco[i].Name, Sprites[fmenu].Image[0]); } else { - AfficheString(140, 120 + i * (360 / 7), Points, Sprites[fmenu].Image[0]); + DrawString(140, 120 + i * (360 / 7), Points, Sprites[fmenu].Image[0]); } } sprintf(Provi, "%i", Pref.Sco[i].Score); - AfficheString(740 - LongueurString(Provi), 120 + i * (360 / 7), Provi, Sprites[fmenu].Image[0]); + DrawString(740 - StringLenght(Provi), 120 + i * (360 / 7), Provi, Sprites[fmenu].Image[0]); } // Efface le fond @@ -1399,7 +1399,7 @@ eMenu Menu::SDLMain_Score(bool EditScore) break; case SDL_TEXTINPUT: /* Add new text onto the end of our text */ - if (LongueurString(Pref.Sco[NEdit].Name) < LSCOREMAX && PosCur < 79 && CharExiste(event.text.text[0])) { + if (StringLenght(Pref.Sco[NEdit].Name) < LSCOREMAX && PosCur < 79 && CharExist(event.text.text[0])) { PosCur += strlen(event.text.text); strcat(Pref.Sco[NEdit].Name, event.text.text); } @@ -1417,12 +1417,12 @@ eMenu Menu::SDLMain_Score(bool EditScore) currentTime = SDL_GetTicks(); Sleeping(); - if (EditScore) { // Gère l'affiche pour l'édition des scores - AfficheString(140, 120 + NEdit * (360 / 7), Pref.Sco[NEdit].Name); + if (EditScore) { // Gère l'Draw pour l'édition des scores + DrawString(140, 120 + NEdit * (360 / 7), Pref.Sco[NEdit].Name); - i = (currentTime / 50) % 20; // Affiche les curseurs + i = (currentTime / 50) % 20; // Draw les curseurs Ec.PrintSprite(arrow_left, i, 110, 120 + NEdit * (360 / 7)); - Ec.PrintSprite(arrow_right, i, 180 + LongueurString(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); + Ec.PrintSprite(arrow_right, i, 180 + StringLenght(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); } // Echange les buffets video @@ -1436,7 +1436,7 @@ eMenu Menu::SDLMain_Score(bool EditScore) return mQuit; } -/*** Affiche le menu Principale ***/ +/*** Draw le menu Principale ***/ /**********************************/ void Menu::Print_Main(int Centre) const { diff --git a/src/screen.cc b/src/screen.cc index e8a38d5..7306925 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -39,7 +39,7 @@ void Screen::PrintSprite(e_Sprite NumSpr, int Num, int x, int y) B[N].y = y; N++; - Sprites[NumSpr].Affiche(x, y, Num); + Sprites[NumSpr].Draw(x, y, Num); } void Screen::PrintCable(int dx, int dy, int fx, int fy) @@ -67,7 +67,7 @@ void Screen::PrintText(e_Sprite Text, int x, int y) B[N].y = y; N++; - Sprites[Text].Affiche(x, y, 0); + Sprites[Text].Draw(x, y, 0); } /*** Affiche les options du jeu ***/ @@ -77,7 +77,7 @@ void Screen::PrintOptions(int NV, int NScore) int x, y; Score = NScore; - AfficheChiffre(740, 215, Score); + DrawNumber(740, 215, Score); if (NV > 10) { NV = 10; // Evite un dépassement de l'affichage @@ -87,7 +87,7 @@ void Screen::PrintOptions(int NV, int NScore) x = x * 44 + 38 + LT * D_Case; y = i / 2; y = 384 + y * 46; - Sprites[logo_vie].Affiche(x, y, 0); + Sprites[logo_vie].Draw(x, y, 0); } } @@ -102,7 +102,7 @@ void Screen::ClearSprite(e_Sprite NumSp) /*******************************************/ void Screen::CleanSpriteAndScreen(e_Sprite NumSp) { - Sprites[NumSp].Affiche(Sprites[NumSp].Dim[0].L / 2, Sprites[NumSp].Dim[0].H / 2, 0); + Sprites[NumSp].Draw(Sprites[NumSp].Dim[0].L / 2, Sprites[NumSp].Dim[0].H / 2, 0); N = 0; Score = -1; } diff --git a/src/sprite.cc b/src/sprite.cc index 4b413da..39f0ec0 100644 --- a/src/sprite.cc +++ b/src/sprite.cc @@ -43,26 +43,26 @@ static int TableTexte[256]; char Langue[31][16]; // Mémorise les noms des langues int NTextes = 0; -bool AfficheC = false; // Si peut afficher le chargeur lors du chargement +bool DrawL = false; // Si peut afficher le chargeur lors du chargement #define N_SPRITESFOND 2 /*** Affiche le chargeur lors du chargement ***/ /**********************************************/ -void AfficheChargeur() +void DrawLoading() { static int NumAf = -1; // Numéro su sprite affiché int i, Old; - int Hor; + int Clock; - if (AfficheC == true) { - Hor = SDL_GetTicks(); - i = (Hor / (1000 / 25)) % Sprites[loading].N; // Calcule le numéro su sprite à afficher + if (DrawL == true) { + Clock = SDL_GetTicks(); + i = (Clock / (1000 / 25)) % Sprites[loading].N; // Calcule le numéro su sprite à afficher if (i != NumAf) { Old = NumAf; NumAf = i; - Sprites[loading].Affiche(400, 300, NumAf); + Sprites[loading].Draw(400, 300, NumAf); SDL_RenderPresent(sdlRenderer); // TODO if(Old!=-1) Sprites[chargeur].Efface(400,300,Old,sdlVideo); } @@ -71,7 +71,7 @@ void AfficheChargeur() /*** Charge les Sprites d'une langue ***/ /***************************************/ -bool LoadLangue() +bool LoadLanguage() { long L, P; int i; @@ -162,7 +162,7 @@ bool LoadSprites() if (Sprites[loading].Load(Buf, P) == false) { return false; // Sprite du chargeur } - AfficheC = true; // Peut afficher le sprite du chargeur + DrawL = true; // Peut afficher le sprite du chargeur delete[] Buf; @@ -179,11 +179,11 @@ bool LoadSprites() // Lit les sprites P = 0; for (i = 0; i < NSp; i++) { - AfficheChargeur(); + DrawLoading(); switch (i) { case fjeu: case fmenu: - if (Sprites[i].Nouveau(800, 600) == false) { + if (Sprites[i].New(800, 600) == false) { return false; } break; @@ -204,16 +204,16 @@ bool LoadSprites() // *** Charge la langue *** // ************************ if (Pref.Language != -1) { - LoadLangue(); + LoadLanguage(); } - AfficheC = false; // N'affiche plus les sprites du chargeur + DrawL = false; // N'affiche plus les sprites du chargeur return true; } /*** Retourne la longueur d'un nombre ***/ /****************************************/ -int LongueurChiffre(int C) +int NumberLenght(int C) { int l = 0; @@ -230,7 +230,7 @@ int LongueurChiffre(int C) /*** Retourne la longueur d'un texte ***/ /***************************************/ -int LongueurString(char *Texte) +int StringLenght(char *Texte) { int i = 0; int l = 0; @@ -258,7 +258,7 @@ int LongueurString(char *Texte) /*** Test si un caracataire existe ***/ /*************************************/ -bool CharExiste(char C) +bool CharExist(char C) { if ((int)(C) < 0) { return false; @@ -273,13 +273,13 @@ bool CharExiste(char C) } /*** Affiche un nombre ***/ /*************************/ -void AfficheChiffre(int x, int y, int Nombre, SDL_Texture *Fond) +void DrawNumber(int x, int y, int Nombre, SDL_Texture *Fond) { - int const l = LongueurChiffre(Nombre); + int const l = NumberLenght(Nombre); x += l / 2; do { - Sprites[digits].Affiche(x - (Sprites[digits].Dim[(Nombre % 10)].L) / 2, y, Nombre % 10, Fond); + Sprites[digits].Draw(x - (Sprites[digits].Dim[(Nombre % 10)].L) / 2, y, Nombre % 10, Fond); x -= Sprites[digits].Dim[(Nombre % 10)].L + ECART_ENTRE_CHIFFRE; Nombre /= 10; } while (Nombre); @@ -287,7 +287,7 @@ void AfficheChiffre(int x, int y, int Nombre, SDL_Texture *Fond) /*** Affiche un Texte ***/ /************************/ -void AfficheString(int x, int y, char *Texte, SDL_Texture *Fond) +void DrawString(int x, int y, char *Texte, SDL_Texture *Fond) { int i = 0; int Le; @@ -298,7 +298,7 @@ void AfficheString(int x, int y, char *Texte, SDL_Texture *Fond) if (TableTexte[Le] != -1) { // Si un caractaire connue Le = TableTexte[Le]; - Sprites[lettres].Affiche(x + (Sprites[lettres].Dim[Le].L / 2), y, Le, Fond); + Sprites[lettres].Draw(x + (Sprites[lettres].Dim[Le].L / 2), y, Le, Fond); x += Sprites[lettres].Dim[Le].L + ECART_ENTRE_LETTRE; } else { // Si un espace @@ -313,9 +313,9 @@ void AfficheString(int x, int y, char *Texte, SDL_Texture *Fond) /*** Affiche un text dans la langue ***/ /**************************************/ -void AfficheText(int x, int y, e_Sprite Text, SDL_Texture *Fond) +void DrawText(int x, int y, e_Sprite Text, SDL_Texture *Fond) { - Sprites[Text].Affiche(x, y, 0, Fond); + Sprites[Text].Draw(x, y, 0, Fond); } /*** Constructeur ***/ @@ -349,7 +349,7 @@ bool Sprite::Load(unsigned char *Buf, long &P) // Lit tous les sprites for (i = 0; i < N; i++) { // Affiche l'animation de chargement - AfficheChargeur(); + DrawLoading(); // Lit les dimensions Dim[i].L = (int)(Buf[P]) * 256 + (int)(Buf[P + 1]); @@ -401,7 +401,7 @@ bool Sprite::Load(unsigned char *Buf, long &P) /*** Affiche le sprite ***/ /*************************/ -void Sprite::Affiche(int X, int Y, int NumSpr, SDL_Texture *Fond) const +void Sprite::Draw(int X, int Y, int NumSpr, SDL_Texture *Fond) const { SDL_Rect Position; SDL_Rect Di; @@ -430,7 +430,7 @@ void Sprite::PrintRope(int dx, int dy, int fx, int fy) /*** Alloue un nouveau sprite vide ***/ /*************************************/ -bool Sprite::Nouveau(int Lx, int Ly) +bool Sprite::New(int Lx, int Ly) { Delete(); // Efface au cas ou diff --git a/src/sprite.h b/src/sprite.h index bcb55ed..1cf16a5 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -174,18 +174,18 @@ enum e_Sprite { /*** Fonctions ***/ /*****************/ -void AfficheChargeur(); // Affiche le chargeur sur la page de départ -bool LoadLangue(); // Charge les sprites d'une langue +void DrawLoading(); // Affiche le chargeur sur la page de départ +bool LoadLanguage(); // Charge les sprites d'une langue bool LoadSprites(); // Charge tous les sprites -int LongueurChiffre(int C); // Retourne la longueur en pixels d'un nombre -int LongueurString(char *Texte); // Retourne la longueur en pixels d'un texte -bool CharExiste(char C); // Si un caracataire existe +int NumberLenght(int C); // Retourne la longueur en pixels d'un nombre +int StringLenght(char *Texte); // Retourne la longueur en pixels d'un texte +bool CharExist(char C); // Si un caracataire existe -void AfficheChiffre(int x, int y, int Nombre, SDL_Texture *Fond = nullptr); // Affiche un chiffre -void AfficheString(int x, int y, char *Texte, SDL_Texture *Fond = nullptr); // Affiche une chaine de caractaire +void DrawNumber(int x, int y, int Nombre, SDL_Texture *Fond = nullptr); // Affiche un chiffre +void DrawString(int x, int y, char *Texte, SDL_Texture *Fond = nullptr); // Affiche une chaine de caractaire -void AfficheText(int x, int y, e_Sprite Text, SDL_Texture *Fond = nullptr); // Affiche un text dans la langue +void DrawText(int x, int y, e_Sprite Text, SDL_Texture *Fond = nullptr); // Affiche un text dans la langue /*** Definition de la classe Sprite ***/ /**************************************/ @@ -197,9 +197,9 @@ class Sprite /*** Fonctions ***/ bool Load(unsigned char *Buf, long &P); // Charge les images - void Affiche(int X, int Y, int NumSpr, SDL_Texture *Fond = nullptr) const; // Affiche un sprite + void Draw(int X, int Y, int NumSpr, SDL_Texture *Fond = nullptr) const; // Affiche un sprite void PrintRope(int dx, int dy, int fx, int fy); - bool Nouveau(int Lx, int Ly); // Alloue un nouveau sprite vide sans transparence + bool New(int Lx, int Ly); // Alloue un nouveau sprite vide sans transparence void Delete(); // Efface la mémoire du sprite /*** Variables ***/ diff --git a/src/utils.cc b/src/utils.cc index bf0925d..9070adf 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -97,7 +97,7 @@ long Utils::LoadFile(const char *Path, unsigned char *&Buf) unsigned char *Po = Buf; while (Compt > 1024) { - AfficheChargeur(); + DrawLoading(); if (SDL_RWread(file, Po, 1, 1024) != 1024) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error while reading '%s'", Path); SDL_RWclose(file); From 9420847a23c04bac01100d5ac5738db56eacb333 Mon Sep 17 00:00:00 2001 From: zabidenhtf Date: Fri, 16 Jan 2026 16:32:16 +0200 Subject: [PATCH 9/9] Fixed small error Lenght->Length --- src/menu.cc | 6 +++--- src/sprite.cc | 6 +++--- src/sprite.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/menu.cc b/src/menu.cc index 776d13e..167a249 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -1352,7 +1352,7 @@ eMenu Menu::SDLMain_Score(bool EditScore) } sprintf(Provi, "%i", Pref.Sco[i].Score); - DrawString(740 - StringLenght(Provi), 120 + i * (360 / 7), Provi, Sprites[fmenu].Image[0]); + DrawString(740 - StringLength(Provi), 120 + i * (360 / 7), Provi, Sprites[fmenu].Image[0]); } // Efface le fond @@ -1399,7 +1399,7 @@ eMenu Menu::SDLMain_Score(bool EditScore) break; case SDL_TEXTINPUT: /* Add new text onto the end of our text */ - if (StringLenght(Pref.Sco[NEdit].Name) < LSCOREMAX && PosCur < 79 && CharExist(event.text.text[0])) { + if (StringLength(Pref.Sco[NEdit].Name) < LSCOREMAX && PosCur < 79 && CharExist(event.text.text[0])) { PosCur += strlen(event.text.text); strcat(Pref.Sco[NEdit].Name, event.text.text); } @@ -1422,7 +1422,7 @@ eMenu Menu::SDLMain_Score(bool EditScore) i = (currentTime / 50) % 20; // Draw les curseurs Ec.PrintSprite(arrow_left, i, 110, 120 + NEdit * (360 / 7)); - Ec.PrintSprite(arrow_right, i, 180 + StringLenght(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); + Ec.PrintSprite(arrow_right, i, 180 + StringLength(Pref.Sco[NEdit].Name), 120 + NEdit * (360 / 7)); } // Echange les buffets video diff --git a/src/sprite.cc b/src/sprite.cc index 39f0ec0..be8881c 100644 --- a/src/sprite.cc +++ b/src/sprite.cc @@ -213,7 +213,7 @@ bool LoadSprites() /*** Retourne la longueur d'un nombre ***/ /****************************************/ -int NumberLenght(int C) +int NumberLength(int C) { int l = 0; @@ -230,7 +230,7 @@ int NumberLenght(int C) /*** Retourne la longueur d'un texte ***/ /***************************************/ -int StringLenght(char *Texte) +int StringLength(char *Texte) { int i = 0; int l = 0; @@ -275,7 +275,7 @@ bool CharExist(char C) /*************************/ void DrawNumber(int x, int y, int Nombre, SDL_Texture *Fond) { - int const l = NumberLenght(Nombre); + int const l = NumberLength(Nombre); x += l / 2; do { diff --git a/src/sprite.h b/src/sprite.h index 1cf16a5..df5f7a2 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -178,8 +178,8 @@ void DrawLoading(); // Affiche le chargeur sur la page de départ bool LoadLanguage(); // Charge les sprites d'une langue bool LoadSprites(); // Charge tous les sprites -int NumberLenght(int C); // Retourne la longueur en pixels d'un nombre -int StringLenght(char *Texte); // Retourne la longueur en pixels d'un texte +int NumberLength(int C); // Retourne la longueur en pixels d'un nombre +int StringLength(char *Texte); // Retourne la longueur en pixels d'un texte bool CharExist(char C); // Si un caracataire existe void DrawNumber(int x, int y, int Nombre, SDL_Texture *Fond = nullptr); // Affiche un chiffre