From e0ab6a482882ef9fdf5644f14ba32808000b17fa Mon Sep 17 00:00:00 2001 From: zulianc Date: Fri, 23 May 2025 22:35:31 +0200 Subject: [PATCH] update readme and main.cpp debug messages --- README.md | 40 ++++++++++++++----- src/Core/GameParameters.h | 2 +- .../AppMenus/GamePiecesAppMenu.cpp | 6 +-- src/GraphicalUI/AppMenus/StartUpAppMenu.cpp | 6 +-- src/GraphicalUI/Settings.cpp | 4 +- src/GraphicalUI/Settings.h | 12 +++--- src/GraphicalUI/main.cpp | 27 ++++++++++--- 7 files changed, 66 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index b847919..0d59caa 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,26 @@ Modern stacker game with every polyominos from size 1 to 15, made in C++ with [S ## Download -// to bo included when release version is done // +// TODO when the game is finished // -This game has been tested on and provides executables for Windows 11 and Linux under Ubuntu only. -If your OS isn't compactible with either of theses two, you can try [manually building the project](#manual-build-and-run). +This game has been tested on and built on Windows 11 and WSL2 Ubuntu only. +If your OS isn't compactible with either of theses two, you can try [manually building the project](#manual-build). ## How to play -### General - You can see and change in-game keybinds in the **SETTINGS** section of the main menu! -All of in-menu navigation is done with the arrow keys, the Enter key and the Escape key. Theses are unmutable keybinds. -You will find some more infos about the Rotation System and the scoring in the **INFO** section of the main menu. -If you want to know more details about the generation and classification of polyominoes, [check the documentation](/doc/)! +All of in-menu navigation is done with the **arrow keys**, the **Enter key** and the **Escape key**. Theses are unchangeable keybinds. +You will find more infos about the Rotation System, the scoring system, or the different pieces type in the **INFO** section of the main menu. +If you want to know more details about the generation of polyominoes, [check the documentation](/doc/)! + +## Features + +- Every polyominoes from size 1 to 15, selectable as you wish, with customizable propotionnality for each size! +- Customizable keybinds! +- 0° rotations! +- AutoRS as the Rotation System! +- IRS, IHS, infinite hold, and other leniency mechanics! +- Very bland interface!! (i'm not a designer) ### Available gamemodes @@ -26,6 +33,10 @@ If you want to know more details about the generation and classification of poly - MASTER : clear 200 lines at levels higher than maximum gravity! - ZEN : practice indefinitely in this mode with no gravity! +### Screenshots + +// TODO when the game is finished // + ## Manual build This project uses xmake for compiling, xmake is cross-platform and works in most OS, xmake also automatically install supported librairies. @@ -43,12 +54,19 @@ If you need to change the toolchain (for example using gcc): ### Run the project ``xmake run`` -Note that the program will generate the polyomino files for you the first time. This lasts several minutes so it only does it up to size 10. If you want to use the full range up to size 15, you will need to uncomment the ``#define`` at line 13 of file ``src/GraphicalUI/Settings.h``. -If for some reasons you wanna run the command line version: +The program will generate the polyomino files for you if you don't have them. +As this is a lengthy process, debug mode limits pieces size to 10. +To switch between debug and release mode: +``xmake f -m debug`` +``xmake f -m release`` + +If for some reasons you wanna run the command line version (not updated): ``xmake run text`` -### Create a release version (xmake packaging ???) +### Package the project + +// TODO when the game is finished // ## Credits diff --git a/src/Core/GameParameters.h b/src/Core/GameParameters.h index 7751765..a0edd4d 100644 --- a/src/Core/GameParameters.h +++ b/src/Core/GameParameters.h @@ -15,7 +15,7 @@ class GameParameters { Player controls; // the player's controls int clearedLines; // the number of cleared lines int level; // the current level - int grade; // the current amount of points + int grade; // the current amount of points int nextQueueLength; // the number of pieces visibles in the next queue bool boneBlocks; // wheter all blocks are bone blocks int gravity; // the gravity at which pieces drop diff --git a/src/GraphicalUI/AppMenus/GamePiecesAppMenu.cpp b/src/GraphicalUI/AppMenus/GamePiecesAppMenu.cpp index efd8c0c..8cdd85f 100644 --- a/src/GraphicalUI/AppMenus/GamePiecesAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/GamePiecesAppMenu.cpp @@ -17,7 +17,7 @@ GamePiecesAppMenu::GamePiecesAppMenu(std::shared_ptr menuStack, std:: this->playerCursor.addRow(i + 1, this->settings->getMenu().readPiecesList().getNumberOfPieces(i) + 4); } - if (this->settings->getMaximumPiecesSize() < GENERATED_PIECES_SIZE) { + if (this->settings->getMaximumPiecesSize() < MAXIMUM_PIECES_SIZE) { this->playerCursor.addRow(this->settings->getMaximumPiecesSize() + 2, 1); } } @@ -43,7 +43,7 @@ void GamePiecesAppMenu::computeFrame() { this->playerCursor.addRow(newMaxSize + 1, this->settings->getMenu().readPiecesList().getNumberOfPieces(newMaxSize) + 4); this->playerCursor.goToPosition({0u, newMaxSize + 1u}); - if (newMaxSize < GENERATED_PIECES_SIZE) { + if (newMaxSize < MAXIMUM_PIECES_SIZE) { this->playerCursor.addRow(newMaxSize + 2, 1); } } @@ -95,7 +95,7 @@ void GamePiecesAppMenu::drawFrame() const { this->drawSelectedPiecesRow(15.f); bool drawFromFirstElem = (this->playerCursor.getPosition().y == 1); - bool addExtraLine = (this->settings->getMaximumPiecesSize() < GENERATED_PIECES_SIZE); + bool addExtraLine = (this->settings->getMaximumPiecesSize() < MAXIMUM_PIECES_SIZE); int firstElem = std::clamp(((int) this->playerCursor.getPosition().y) - 2, 1, this->settings->getMaximumPiecesSize() - 2 + (addExtraLine ? 1 : 0)); this->drawRow(firstElem, 25.f, drawFromFirstElem); this->drawRow(firstElem + 1, 35.f, drawFromFirstElem); diff --git a/src/GraphicalUI/AppMenus/StartUpAppMenu.cpp b/src/GraphicalUI/AppMenus/StartUpAppMenu.cpp index c11f4ae..3c01c6f 100644 --- a/src/GraphicalUI/AppMenus/StartUpAppMenu.cpp +++ b/src/GraphicalUI/AppMenus/StartUpAppMenu.cpp @@ -12,9 +12,9 @@ StartUpAppMenu::StartUpAppMenu(std::shared_ptr menuStack, std::shared_ptr settings, std::shared_ptr renderWindow) : AppMenu(menuStack, settings, renderWindow), - playerCursor({GENERATED_PIECES_SIZE + 1}) { + playerCursor({MAXIMUM_PIECES_SIZE + 1}) { - this->playerCursor.goToPosition({(unsigned int) std::clamp(this->settings->getMaximumPiecesSize(), MINIMUM_PIECES_SIZE, GENERATED_PIECES_SIZE), 0u}); + this->playerCursor.goToPosition({(unsigned int) std::clamp(this->settings->getMaximumPiecesSize(), MINIMUM_PIECES_SIZE, MAXIMUM_PIECES_SIZE), 0u}); } void StartUpAppMenu::computeFrame() { @@ -23,7 +23,7 @@ void StartUpAppMenu::computeFrame() { if (this->playerCursor.getPosition().x < MINIMUM_PIECES_SIZE) { if (this->playerCursor.movedLeft()) { - this->playerCursor.goToPosition({GENERATED_PIECES_SIZE, 0}); + this->playerCursor.goToPosition({MAXIMUM_PIECES_SIZE, 0}); } else { this->playerCursor.goToPosition({MINIMUM_PIECES_SIZE, 0}); diff --git a/src/GraphicalUI/Settings.cpp b/src/GraphicalUI/Settings.cpp index 3f2eb24..e859bf1 100644 --- a/src/GraphicalUI/Settings.cpp +++ b/src/GraphicalUI/Settings.cpp @@ -31,8 +31,8 @@ void Settings::loadPieces(int maximumPiecesSizeRequest) { if (maximumPiecesSizeRequest < MINIMUM_PIECES_SIZE) { maximumPiecesSizeRequest = MINIMUM_PIECES_SIZE; } - else if (maximumPiecesSizeRequest > GENERATED_PIECES_SIZE || maximumPiecesSizeRequest > MAXIMUM_PIECES_SIZE) { - maximumPiecesSizeRequest = GENERATED_PIECES_SIZE; + else if (maximumPiecesSizeRequest > MAXIMUM_PIECES_SIZE) { + maximumPiecesSizeRequest = MAXIMUM_PIECES_SIZE; } bool succeeded = true; diff --git a/src/GraphicalUI/Settings.h b/src/GraphicalUI/Settings.h index c4cf871..a7ce305 100644 --- a/src/GraphicalUI/Settings.h +++ b/src/GraphicalUI/Settings.h @@ -13,14 +13,14 @@ static const int CURRENT_FILE_FORMAT_VERSION = 11; static const int MAXIMUM_BOARD_WIDTH = 40; static const int MAXIMUM_BOARD_HEIGHT = 40; -static const int MINIMUM_PIECES_SIZE = 4; -static const int MAXIMUM_PIECES_SIZE = 15; +static const int RELEASE_PIECES_SIZE = 15; +static const int DEBUG_PIECES_SIZE = 10; -#define __JMINOS_RELEASE__ -#ifdef __JMINOS_RELEASE__ -static const int GENERATED_PIECES_SIZE = 15; +static const int MINIMUM_PIECES_SIZE = 4; +#ifdef NDEBUG +static const int MAXIMUM_PIECES_SIZE = RELEASE_PIECES_SIZE; #else -static const int GENERATED_PIECES_SIZE = 10; +static const int MAXIMUM_PIECES_SIZE = DEBUG_PIECES_SIZE; #endif static const std::pair DEFAULT_SELECTION = {ALL_PIECES, MINIMUM_PIECES_SIZE}; diff --git a/src/GraphicalUI/main.cpp b/src/GraphicalUI/main.cpp index eef0472..f56ba73 100644 --- a/src/GraphicalUI/main.cpp +++ b/src/GraphicalUI/main.cpp @@ -13,15 +13,32 @@ int main() { std::srand(std::time(NULL)); PiecesFiles pf; - for (int i = 1; i <= GENERATED_PIECES_SIZE; i++) { + for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) { if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) { - std::cout << "pieces files for size " << i << " not found, generating..." << std::endl; + #ifdef NDEBUG + std::cout << "IMPORTANT: You are currently in release mode, if you do not wish to generate big pieces (can take several minutes), type 'xmake f -m debug'." << std::endl; + #endif + + std::cout << "INFO: Pieces files for size " << i << " not found, generating..." << std::endl; pf.savePieces(i); } } + #ifndef NDEBUG + std::cout << "IMPORTANT: you are currently in debug mode, if you wish to use bigger pieces, type 'xmake f -m release'." << std::endl; + + bool everythingGenerated = true; + for (int i = DEBUG_PIECES_SIZE; i <= RELEASE_PIECES_SIZE; i++) { + if (!std::filesystem::exists("data/pieces/" + std::to_string(i) + "minos.bin")) { + everythingGenerated = false; + } + } + if (!everythingGenerated) { + std::cout << "NOTE : you do not have all pieces generated, generating can take several minutes." << std::endl; + } + #endif if (!std::filesystem::exists("data/config/settings.bin")) { - std::cout << "settings file not found, generating..." << std::endl; + std::cout << "INFO: Settings file not found, generating..." << std::endl; resetSettingsFile(); } else { @@ -30,7 +47,7 @@ int main() { settingsFile.get(byte); if ((unsigned char) byte < CURRENT_FILE_FORMAT_VERSION) { - std::cout << "files format changed, regenerating..." << std::endl; + std::cout << "INFO: Files format changed, regenerating..." << std::endl; resetSettingsFile(); for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) { resetKeybindFile(i); @@ -40,7 +57,7 @@ int main() { for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) { if (!std::filesystem::exists("data/config/keybinds/layout" + std::to_string(i) + ".bin")) { - std::cout << "keybind file n°" << (i + 1) << "/" << NUMBER_OF_KEYBINDS << " not found, generating..." << std::endl; + std::cout << "INFO: Keybind file n°" << (i + 1) << "/" << NUMBER_OF_KEYBINDS << " not found, generating..." << std::endl; resetKeybindFile(i); } }