The Table Engine
|
Manages the main game loop, rendering, and application state. More...
#include <gameapp.h>
Public Member Functions | |
GameApplication (std::string title) | |
Constructs a GameApplication with a specified window title. More... | |
~GameApplication () | |
Destructor that cleans up SDL resources. More... | |
void | printStats () |
Prints current game statistics like FPS. More... | |
void | start (bool demo) |
Starts the game application, initializing all necessary resources. More... | |
void | input () |
Processes input from the user. This function should be called in the game loop to handle events like keystrokes and mouse movements. More... | |
void | update () |
Updates the game state. This function should be called once per frame to update the state of the game, including game objects. More... | |
void | render () |
Renders the game state to the window. This function should be called once per frame to draw all game visuals. More... | |
void | advanceFrame () |
Advances the game frame, updating timing and FPS calculations. More... | |
void | runLoop () |
The main game loop that runs continuously while the game is active. This loop calls the input, update, and render functions in sequence. More... | |
Public Attributes | |
SDL_Window * | m_window = NULL |
Pointer to the SDL_Window. More... | |
SDL_Renderer * | m_renderer = NULL |
Pointer to the SDL_Renderer used for all rendering in the game. More... | |
bool | m_gameIsRunning = true |
Flag to control the game loop. More... | |
float | m_FPS = 0 |
Frames per second, updated during the game loop to measure performance. More... | |
Manages the main game loop, rendering, and application state.
GameApplication is responsible for setting up the SDL window and renderer, and it controls the main execution loop of the game. It also handles basic performance statistics like FPS and provides mechanisms for game state updates and rendering.
GameApplication::GameApplication | ( | std::string | title | ) |
Constructs a GameApplication with a specified window title.
title | The title for the game window. |
Definition at line 21 of file gameapp.cpp.
GameApplication::~GameApplication | ( | ) |
Destructor that cleans up SDL resources.
Definition at line 40 of file gameapp.cpp.
void GameApplication::advanceFrame | ( | ) |
Advances the game frame, updating timing and FPS calculations.
Definition at line 152 of file gameapp.cpp.
void GameApplication::input | ( | ) |
Processes input from the user. This function should be called in the game loop to handle events like keystrokes and mouse movements.
Definition at line 125 of file gameapp.cpp.
void GameApplication::printStats | ( | ) |
Prints current game statistics like FPS.
Definition at line 68 of file gameapp.cpp.
void GameApplication::render | ( | ) |
Renders the game state to the window. This function should be called once per frame to draw all game visuals.
Definition at line 142 of file gameapp.cpp.
void GameApplication::runLoop | ( | ) |
The main game loop that runs continuously while the game is active. This loop calls the input, update, and render functions in sequence.
Definition at line 158 of file gameapp.cpp.
void GameApplication::start | ( | bool | demo = false | ) |
Starts the game application, initializing all necessary resources.
Definition at line 47 of file gameapp.cpp.
void GameApplication::update | ( | ) |
Updates the game state. This function should be called once per frame to update the state of the game, including game objects.
Definition at line 138 of file gameapp.cpp.
float GameApplication::m_FPS = 0 |
bool GameApplication::m_gameIsRunning = true |
SDL_Renderer* GameApplication::m_renderer = NULL |
SDL_Window* GameApplication::m_window = NULL |