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

View File

@@ -4,15 +4,19 @@
#include "Player.h"
#include "Game.h"
#include <memory>
Menu::Menu() {
this->piecesList = std::make_shared<PiecesList>(PiecesList());
// default board size
this->boardHeight = 20;
this->boardWidth = 10;
}
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) {
@@ -42,5 +46,5 @@ Player& Menu::getPlayerControls() {
}
PiecesList& Menu::getPiecesList() {
return this->piecesList;
return *this->piecesList;
}

View File

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