My Project
UML Lab
|
Represents the main game logic and interaction. More...
#include <gameloop.h>
Public Member Functions | |
Game (sf::RenderWindow &window, Player &humanPlayer, Player &computerPlayer) | |
Constructs a Game object. | |
void | run () |
Runs the main game loop. | |
Private Attributes | |
Board | board |
Instance of the Board class, representing the game board. | |
Player & | humanPlayer |
Reference to the Player object representing the human player. | |
Player & | computerPlayer |
Reference to the Player object representing the computer player. | |
sf::RenderWindow & | window |
Reference to the SFML RenderWindow for displaying the game. | |
Represents the main game logic and interaction.
This class manages the core gameplay loop, including drawing the board, handling input, and facilitating turns between the human and computer players. It holds references to the game window, the board, and the player objects.
Constructs a Game object.
Initializes a Game instance with references to the necessary components: the game window, human player, computer player, and the board (which is created internally).
window | Reference to the SFML RenderWindow used for rendering. |
humanPlayer | Reference to the Player object representing the human player. |
computerPlayer | Reference to the Player object representing the computer player. |
Initializes a Game instance, associating it with a RenderWindow, two Player objects (human and computer), and a Board to manage the game state.
void Game::run | ( | ) |
Runs the main game loop.
This function initiates the core game loop. It continuously:
The loop continues until the game window is closed.
This function handles the continuous cycle of the game:
The loop continues until the window is closed.
|
private |
Reference to the Player object representing the computer player.
|
private |
Reference to the SFML RenderWindow for displaying the game.