![]() |
R-Type
2
Doom but in better
|
Represents the main game logic and state management. More...
#include <Game.hpp>
Public Member Functions | |
Game () | |
Constructs a new Game object. | |
~Game () | |
Destroys the Game object. | |
void | update (float _deltaTime) |
Updates the game state for the current frame. | |
std::forward_list< std::string > | getGameEvents (void) |
Retrieves game messages. | |
std::forward_list< std::string > | getCurrentGameState (void) |
Gets the current game state (syncing) | |
void | onServerEventReceived (std::string &event) |
Handles an event received from server. | |
void | onGameEventReceived (const GameMessage &event) |
Handles an event received during gameplay. | |
Represents the main game logic and state management.
The Game
class manages the overall game state, handles events, and updates the game loop. It integrates with a Registry
to manage game entities and their components and uses an EventDispatcher
to handle game events. The class allows for event handling and periodic updates based on the elapsed time.
Game::Game | ( | ) |
Constructs a new Game
object.
Initializes the game state, the Registry
, and the EventDispatcher
to set up the game environment.
Game::~Game | ( | ) |
Destroys the Game
object.
Cleans up resources used by the game, including the Registry
and EventDispatcher
.
std::forward_list< std::string > Game::getCurrentGameState | ( | void | ) |
std::forward_list< std::string > Game::getGameEvents | ( | void | ) |
void Game::onGameEventReceived | ( | const GameMessage & | event | ) |
Handles an event received during gameplay.
This function processes incoming game events, allowing the game to respond to various triggers such as player actions or system events.
event | The game event to be processed, represented as a GameMessage . |
void Game::onServerEventReceived | ( | std::string & | event | ) |
void Game::update | ( | float | _deltaTime | ) |
Updates the game state for the current frame.
This function processes the game loop, updating game logic, entities, and handling events. It is typically called once per frame, with deltaTime
representing the time elapsed since the last frame to ensure smooth and consistent gameplay.
_deltaTime | The time elapsed since the last frame, used to update game entities and logic. |