update readme and main.cpp debug messages

This commit is contained in:
2025-05-23 22:35:31 +02:00
parent a62b3c018d
commit e0ab6a4828
7 changed files with 66 additions and 31 deletions

View File

@@ -4,19 +4,26 @@ Modern stacker game with every polyominos from size 1 to 15, made in C++ with [S
## Download ## 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. 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-and-run). If your OS isn't compactible with either of theses two, you can try [manually building the project](#manual-build).
## How to play ## How to play
### General
You can see and change in-game keybinds in the **SETTINGS** section of the main menu! 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. 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 some more infos about the Rotation System and the scoring in the **INFO** section of the main menu. 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 and classification of polyominoes, [check the documentation](/doc/)! 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 ### 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! - MASTER : clear 200 lines at levels higher than maximum gravity!
- ZEN : practice indefinitely in this mode with no gravity! - ZEN : practice indefinitely in this mode with no gravity!
### Screenshots
// TODO when the game is finished //
## Manual build ## Manual build
This project uses xmake for compiling, xmake is cross-platform and works in most OS, xmake also automatically install supported librairies. 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 ### Run the project
``xmake run`` ``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`` ``xmake run text``
### Create a release version (xmake packaging ???) ### Package the project
// TODO when the game is finished //
## Credits ## Credits

View File

@@ -15,7 +15,7 @@ class GameParameters {
Player controls; // the player's controls Player controls; // the player's controls
int clearedLines; // the number of cleared lines int clearedLines; // the number of cleared lines
int level; // the current level 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 int nextQueueLength; // the number of pieces visibles in the next queue
bool boneBlocks; // wheter all blocks are bone blocks bool boneBlocks; // wheter all blocks are bone blocks
int gravity; // the gravity at which pieces drop int gravity; // the gravity at which pieces drop

View File

@@ -17,7 +17,7 @@ GamePiecesAppMenu::GamePiecesAppMenu(std::shared_ptr<MenuStack> menuStack, std::
this->playerCursor.addRow(i + 1, this->settings->getMenu().readPiecesList().getNumberOfPieces(i) + 4); 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); 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.addRow(newMaxSize + 1, this->settings->getMenu().readPiecesList().getNumberOfPieces(newMaxSize) + 4);
this->playerCursor.goToPosition({0u, newMaxSize + 1u}); this->playerCursor.goToPosition({0u, newMaxSize + 1u});
if (newMaxSize < GENERATED_PIECES_SIZE) { if (newMaxSize < MAXIMUM_PIECES_SIZE) {
this->playerCursor.addRow(newMaxSize + 2, 1); this->playerCursor.addRow(newMaxSize + 2, 1);
} }
} }
@@ -95,7 +95,7 @@ void GamePiecesAppMenu::drawFrame() const {
this->drawSelectedPiecesRow(15.f); this->drawSelectedPiecesRow(15.f);
bool drawFromFirstElem = (this->playerCursor.getPosition().y == 1); 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)); 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, 25.f, drawFromFirstElem);
this->drawRow(firstElem + 1, 35.f, drawFromFirstElem); this->drawRow(firstElem + 1, 35.f, drawFromFirstElem);

View File

@@ -12,9 +12,9 @@
StartUpAppMenu::StartUpAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) : StartUpAppMenu::StartUpAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
AppMenu(menuStack, settings, 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() { void StartUpAppMenu::computeFrame() {
@@ -23,7 +23,7 @@ void StartUpAppMenu::computeFrame() {
if (this->playerCursor.getPosition().x < MINIMUM_PIECES_SIZE) { if (this->playerCursor.getPosition().x < MINIMUM_PIECES_SIZE) {
if (this->playerCursor.movedLeft()) { if (this->playerCursor.movedLeft()) {
this->playerCursor.goToPosition({GENERATED_PIECES_SIZE, 0}); this->playerCursor.goToPosition({MAXIMUM_PIECES_SIZE, 0});
} }
else { else {
this->playerCursor.goToPosition({MINIMUM_PIECES_SIZE, 0}); this->playerCursor.goToPosition({MINIMUM_PIECES_SIZE, 0});

View File

@@ -31,8 +31,8 @@ void Settings::loadPieces(int maximumPiecesSizeRequest) {
if (maximumPiecesSizeRequest < MINIMUM_PIECES_SIZE) { if (maximumPiecesSizeRequest < MINIMUM_PIECES_SIZE) {
maximumPiecesSizeRequest = MINIMUM_PIECES_SIZE; maximumPiecesSizeRequest = MINIMUM_PIECES_SIZE;
} }
else if (maximumPiecesSizeRequest > GENERATED_PIECES_SIZE || maximumPiecesSizeRequest > MAXIMUM_PIECES_SIZE) { else if (maximumPiecesSizeRequest > MAXIMUM_PIECES_SIZE) {
maximumPiecesSizeRequest = GENERATED_PIECES_SIZE; maximumPiecesSizeRequest = MAXIMUM_PIECES_SIZE;
} }
bool succeeded = true; bool succeeded = true;

View File

@@ -13,14 +13,14 @@ static const int CURRENT_FILE_FORMAT_VERSION = 11;
static const int MAXIMUM_BOARD_WIDTH = 40; static const int MAXIMUM_BOARD_WIDTH = 40;
static const int MAXIMUM_BOARD_HEIGHT = 40; static const int MAXIMUM_BOARD_HEIGHT = 40;
static const int MINIMUM_PIECES_SIZE = 4; static const int RELEASE_PIECES_SIZE = 15;
static const int MAXIMUM_PIECES_SIZE = 15; static const int DEBUG_PIECES_SIZE = 10;
#define __JMINOS_RELEASE__ static const int MINIMUM_PIECES_SIZE = 4;
#ifdef __JMINOS_RELEASE__ #ifdef NDEBUG
static const int GENERATED_PIECES_SIZE = 15; static const int MAXIMUM_PIECES_SIZE = RELEASE_PIECES_SIZE;
#else #else
static const int GENERATED_PIECES_SIZE = 10; static const int MAXIMUM_PIECES_SIZE = DEBUG_PIECES_SIZE;
#endif #endif
static const std::pair<PiecesType, int> DEFAULT_SELECTION = {ALL_PIECES, MINIMUM_PIECES_SIZE}; static const std::pair<PiecesType, int> DEFAULT_SELECTION = {ALL_PIECES, MINIMUM_PIECES_SIZE};

View File

@@ -13,15 +13,32 @@ int main() {
std::srand(std::time(NULL)); std::srand(std::time(NULL));
PiecesFiles pf; 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")) { 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); 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")) { 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(); resetSettingsFile();
} }
else { else {
@@ -30,7 +47,7 @@ int main() {
settingsFile.get(byte); settingsFile.get(byte);
if ((unsigned char) byte < CURRENT_FILE_FORMAT_VERSION) { 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(); resetSettingsFile();
for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) { for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) {
resetKeybindFile(i); resetKeybindFile(i);
@@ -40,7 +57,7 @@ int main() {
for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) { for (int i = 0; i < NUMBER_OF_KEYBINDS; i++) {
if (!std::filesystem::exists("data/config/keybinds/layout" + std::to_string(i) + ".bin")) { 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); resetKeybindFile(i);
} }
} }