smarter & pointier

This commit is contained in:
2025-03-03 12:00:39 +01:00
parent 47d3d929db
commit d029589c21
6 changed files with 19 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -4,15 +4,19 @@
#include "Player.h" #include "Player.h"
#include "Game.h" #include "Game.h"
#include <memory>
Menu::Menu() { Menu::Menu() {
this->piecesList = std::make_shared<PiecesList>(PiecesList());
// default board size // default board size
this->boardHeight = 20; this->boardHeight = 20;
this->boardWidth = 10; this->boardWidth = 10;
} }
Game Menu::startGame(Gamemode gamemode) const { Game Menu::startGame(Gamemode gamemode) const {
return Game(gamemode, this->playerControls, this->boardWidth, this->boardHeight, std::make_shared<PiecesList>(this->piecesList)); return Game(gamemode, this->playerControls, this->boardWidth, this->boardHeight, this->piecesList);
} }
bool Menu::setBoardWidth(int width) { bool Menu::setBoardWidth(int width) {
@@ -42,5 +46,5 @@ Player& Menu::getPlayerControls() {
} }
PiecesList& Menu::getPiecesList() { PiecesList& Menu::getPiecesList() {
return this->piecesList; return *this->piecesList;
} }

View File

@@ -12,7 +12,7 @@ static const int FRAMES_PER_SECOND = 60; // the number of frames per second, all
*/ */
class Menu { class Menu {
private: private:
PiecesList piecesList; // the list of pieces in the game std::shared_ptr<PiecesList> piecesList; // the list of pieces in the game
Player playerControls; // the controls of the player Player playerControls; // the controls of the player
int boardWidth; // the width of the board for the next game int boardWidth; // the width of the board for the next game
int boardHeight; // the height of the board for the next game int boardHeight; // the height of the board for the next game

View File

@@ -195,11 +195,13 @@ void TextApp::startGame() const {
} }
} }
if (!quit) {
std::cout << "\n\n\n"; std::cout << "\n\n\n";
if (paused) { if (paused) {
std::cout << "--<[PAUSED]>--" << std::endl; std::cout << "--<[PAUSED]>--" << std::endl;
} }
this->printGame(game); this->printGame(game);
}
if (game.hasLost()) { if (game.hasLost()) {
quit = true; quit = true;

View File

@@ -18,6 +18,9 @@ void readStatsFromFilesForAllSizes(int amount);
int main(int argc, char** argv) { int main(int argc, char** argv) {
std::srand(std::time(NULL)); std::srand(std::time(NULL));
// dev: generate files if it hasn't been done before, UI will NOT generate the files
//generateFilesForAllSizes(10);
TextApp UI; TextApp UI;
UI.run(); UI.run();