meilleurs coms ig

This commit is contained in:
2025-03-03 22:34:46 +01:00
parent d029589c21
commit 2fbe4a6052
13 changed files with 56 additions and 78 deletions

View File

@@ -10,12 +10,12 @@
#include <cstdlib>
#include <exception>
static const int FRAMES_PER_INPUT = FRAMES_PER_SECOND / 2;
static const int MAXIMUM_PIECE_SIZE = 10;
static const int DEFAULT_PIECE_SIZE = 4;
static const int MAXIMUM_BOARD_WIDTH = 30;
static const int MAXIMUM_BOARD_HEIGHT = 40;
static const Gamemode DEFAULT_GAMEMODE = SPRINT;
static const int FRAMES_PER_INPUT = FRAMES_PER_SECOND / 2; // the number of frames that will pass everytime the player gives an input
static const int MAXIMUM_PIECE_SIZE = 10; // the maximum size of pieces that will be loaded and utilizable
static const int DEFAULT_PIECE_SIZE = 4; // the default size of pieces that will be selected when first running the app
static const int MAXIMUM_BOARD_WIDTH = 30; // the maximum selectable width of the board
static const int MAXIMUM_BOARD_HEIGHT = 40; // the maximum selectable height of the board
static const Gamemode DEFAULT_GAMEMODE = SPRINT; // the gamemode that will be used when starting a new game
TextApp::TextApp() {
@@ -31,8 +31,6 @@ TextApp::TextApp() {
void TextApp::run() {
bool quit = false;
std::string answer;
int selectedAnswer = 0;
while (!quit) {
std::cout << "\n\n\n";
std::cout << "===| WELCOME TO JMINOS! |===" << std::endl;
@@ -42,7 +40,10 @@ void TextApp::run() {
std::cout << "4- Start game" << std::endl;
std::cout << "5- Quit" << std::endl;
std::cout << "Choice: ";
std::string answer;
std::getline(std::cin, answer);
int selectedAnswer = 0;
try {
selectedAnswer = std::stoi(answer);
}
@@ -232,6 +233,7 @@ void TextApp::printGame(const Game& game) const {
for (int y = maxHeight; y >= 0; y--) {
for (int x = 0; x < game.getBoard().getWidth(); x++) {
/* BOARD PRINTING */
bool isActivePieceHere = (game.getActivePiece() != nullptr) && (game.getActivePiece()->getPositions().contains(Position{x, y} - game.getActivePiecePosition()));
bool isGhostPieceHere = (game.getActivePiece() != nullptr) && (game.getActivePiece()->getPositions().contains(Position{x, y} - game.ghostPiecePosition()));
Block block = (isActivePieceHere || isGhostPieceHere) ? game.getActivePiece()->getBlockType() : game.getBoard().getBlock(Position{x, y});
@@ -262,6 +264,7 @@ void TextApp::printGame(const Game& game) const {
}
if (y < game.getBoard().getGridHeight()) {
/* SIDEBAR PRINTING */
std::cout << " ";
if (!lineCountPrinted) {
std::cout << getResetConsoleColorCode() << "Lines: " << game.getClearedLines();