0% found this document useful (0 votes)
25 views3 pages

Game H

Uploaded by

wijifal264
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Game H

Uploaded by

wijifal264
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#ifndef GAME_H

#define GAME_H
#include "Brick.h"
#include "Board.h"
#include "Observable.h"
#include "Shapes_Container.h"
#include <memory>

namespace Tetris
{

/**
* @brief Represents the game logic for Tetris.
*/
class Game : public Observable{
public:
/**
* @brief Deleted default constructor.
*/
Game() = delete;
/**
* @brief Constructs a game instance with the specified parameters.
* @param height The height of the game board.
* @param width The width of the game board.
* @param lvl The initial level of the game.
* @param partially_filled Boolean indicating whether the board should be
partially filled.
*/
Game(unsigned height,unsigned width,unsigned lvl, bool partially_filled) :
level(lvl), board(height,width,partially_filled),score(0),rowcpt(0),
gameOver(false),currentBrick(nullptr), shapesContainer(), pause(true){}
/**
* @brief Retrieves the current piece in the game.
* @return A reference to the current piece.
*/
inline const Brick& getCurrentBrick() const {return *currentBrick;}
/**
* @brief Retrieves the current board of the game.
* @return A reference to the current board.
*/
inline const Board& getBoard() const {return board;}
/**
* @brief Retrieves the current score of the game.
* @return The current score.
*/
inline const unsigned getScore() const {return score;}
/**
* @brief Retrieves the number of rows completed in the game.
* @return The current number of completed rows.
*/
inline const unsigned getRowCpt() const {return rowcpt;}
/**
* @brief Retrieves the current level of the game.
* @return The current level.
*/
inline const unsigned getLevel() const {return level;}
/**
* @brief Checks if the game is over.
* @return True if the game is over, false otherwise.
*/
inline const bool isGameOver() const {return gameOver;}

inline const bool isPause() const {return pause;}


/**
* @brief Checks if the player has won.
* @return True if the player won, false otherwise.
*/
const bool checkHasWon() ;

private:
/**
* @brief Starts the game.
*/
void startGame();
/**
*@brief Sets the pause status of the game.
*@param status The boolean indicating whether to pause the game or not.
*/
void setPause(const bool& status);
/**
* @brief Ends the game.
*/
void endGame();
/**
* @brief Sets the game level.
* @param lvl The level to set the game to.
*/
void setLevel(const unsigned lvl);
/**
* @brief Moves the current brick in the specified direction.
* @param dir The direction in which to move the current brick.
* @return bool true if the brick moved
*/
bool move(const Direction& dir);
/**
* @brief Rotates the current brick in the specified direction.
* @param dir The direction in which to rotate the current brick.
*/
void rotate(const Direction& dir);
/**
* @brief Moves the brick down until it encounters an obstacle.
*/
void dropCurrentBrick();
/**
* @brief Advances to the next current brick and handles scoring and level
updating.
*/
void nextCurrentBrick();

friend class Controller;


friend class GameTest;

std::unique_ptr<Brick> currentBrick; ///< The current brick in the game.


Board board; ///< The game board.
unsigned score; ///< The current score.
unsigned rowcpt;///< The rows completed
unsigned level; ///< The current level.
bool pause; ///< Indicates if the game is in pause.
bool gameOver; ///< Indicates if the game is over.
Shapes_Container shapesContainer; ///< Container for storing bricks.
};

} // Tetris

#endif // GAME_H

You might also like