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

@@ -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

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);
}
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);

View File

@@ -12,9 +12,9 @@
StartUpAppMenu::StartUpAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> 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});

View File

@@ -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;

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_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<PiecesType, int> DEFAULT_SELECTION = {ALL_PIECES, MINIMUM_PIECES_SIZE};

View File

@@ -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);
}
}