The Table Engine
GameApplication Struct Reference

Manages the main game loop, rendering, and application state. More...

#include <gameapp.h>

+ Collaboration diagram for GameApplication:

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...
 

Detailed Description

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.

Definition at line 22 of file gameapp.h.

Constructor & Destructor Documentation

◆ GameApplication()

GameApplication::GameApplication ( std::string  title)

Constructs a GameApplication with a specified window title.

Parameters
titleThe title for the game window.

Definition at line 21 of file gameapp.cpp.

◆ ~GameApplication()

GameApplication::~GameApplication ( )

Destructor that cleans up SDL resources.

Definition at line 40 of file gameapp.cpp.

Member Function Documentation

◆ advanceFrame()

void GameApplication::advanceFrame ( )

Advances the game frame, updating timing and FPS calculations.

Definition at line 152 of file gameapp.cpp.

◆ input()

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.

◆ printStats()

void GameApplication::printStats ( )

Prints current game statistics like FPS.

Definition at line 68 of file gameapp.cpp.

◆ render()

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.

◆ runLoop()

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.

◆ start()

void GameApplication::start ( bool  demo = false)

Starts the game application, initializing all necessary resources.

Definition at line 47 of file gameapp.cpp.

◆ update()

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.

Member Data Documentation

◆ m_FPS

float GameApplication::m_FPS = 0

Frames per second, updated during the game loop to measure performance.

Definition at line 28 of file gameapp.h.

◆ m_gameIsRunning

bool GameApplication::m_gameIsRunning = true

Flag to control the game loop.

Definition at line 26 of file gameapp.h.

◆ m_renderer

SDL_Renderer* GameApplication::m_renderer = NULL

Pointer to the SDL_Renderer used for all rendering in the game.

Definition at line 24 of file gameapp.h.

◆ m_window

SDL_Window* GameApplication::m_window = NULL

Pointer to the SDL_Window.

Definition at line 23 of file gameapp.h.


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