R-Type  2
Doom but in better
Loading...
Searching...
No Matches
Game Class Reference

Represents the main game logic and state management. More...

#include <Game.hpp>

Collaboration diagram for Game:
Collaboration graph

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.
 

Detailed Description

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.

Definition at line 20 of file Game.hpp.

Constructor & Destructor Documentation

◆ Game()

Game::Game ( )

Constructs a new Game object.

Initializes the game state, the Registry, and the EventDispatcher to set up the game environment.

Definition at line 7 of file Game.cpp.

◆ ~Game()

Game::~Game ( )

Destroys the Game object.

Cleans up resources used by the game, including the Registry and EventDispatcher.

Definition at line 17 of file Game.cpp.

Member Function Documentation

◆ getCurrentGameState()

std::forward_list< std::string > Game::getCurrentGameState ( void )

Gets the current game state (syncing)

This function returns a list of std::string objects. These messages can be used to get the current game state.

Returns
A forward list of std::string objects.

Definition at line 47 of file Game.cpp.

◆ getGameEvents()

std::forward_list< std::string > Game::getGameEvents ( void )

Retrieves game messages.

This function returns a list of std::string objects. These messages can be used to track game events or game state transitions.

Returns
A forward list of std::string objects.

Definition at line 30 of file Game.cpp.

◆ onGameEventReceived()

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.

Parameters
eventThe game event to be processed, represented as a GameMessage.

Definition at line 42 of file Game.cpp.

◆ onServerEventReceived()

void Game::onServerEventReceived ( std::string & event)

Handles an event received from server.

This function processes incoming events from server.

Parameters
eventThe game event to be processed, represented as a std::string.

Definition at line 58 of file Game.cpp.

◆ update()

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.

Parameters
_deltaTimeThe time elapsed since the last frame, used to update game entities and logic.

Definition at line 24 of file Game.cpp.


The documentation for this class was generated from the following files: