Polygon Dash
Loading...
Searching...
No Matches
GameApplication Struct Reference

Main game application. More...

Public Member Functions

 this (string title, uint fps)
 The width of the game window.
 
 ~this ()
 Cleanup the game when destroyed.
 
void PushScene (SceneType scene_type, string level)
 Add a new scene to the list of scenes.
 
void PopScene ()
 Pop the last scene in the listt off.
 
void LoadScene ()
 Load the current scene data into the game.
 
SceneNode CreateMenuScene ()
 Create a SceneNode for the main menu.
 
SceneNode CreateDefaultLevelsMenuScene ()
 Create a SceneNode for the level selector menu.
 
SceneNode CreateLevelScene (string level)
 Create a SceneNode for a game level.
 
void Input ()
 Read and store keyboard and mouse input.
 
void Update ()
 Update the state of all GameObject components (both IComponent and ComponentScript objects).
 
void CheckClickables ()
 Check all clickable objects for click events.
 
void UpdateGameIsRunning ()
 Check whether the game should continue running.
 
void UngroundPlayer ()
 Marks the player as free falling.
 
void CheckForLanding ()
 Checks whether the player will land on an object due to gravity, and restricts its motion if so.
 
void UpdateCollisions ()
 Checks whether the player hit any enemy objects.
 
void Render ()
 Render all GameObject entities.
 
void AdvanceFrame ()
 Take one frame's worth of actions.
 
void RunLoop ()
 Run the game.
 

Public Attributes

SDL_Window * mWindow = null
 The SDL window.
 
SDL_Renderer * mRenderer = null
 The SDL renderer.
 
bool mGameIsRunning = true
 Whether the game is running.
 
string currentLevelName
 The name of the current level.
 
uint max_frame_duration
 The maximum time available until the next frame must render.
 
SDL_Rect * mCamera = null
 The camera placement and size.
 
SceneNode[] scenes
 
SceneNode root
 All available scenes in the game.
 
SceneNode startButtonNode
 The root of the current scene tree.
 
SceneNode playerNode
 A pointer to the start button scene tree node if it exists in the current scene.
 
SceneNode collidableNode
 A pointer to the player GameObject node if it exists in the current scene.
 
SceneNode finishLineNode
 A pointer to the collection of collidable GameObjects if it exists in the current scene.
 
SceneNode attemptNode
 A pointer to the finidh line GameObject node if it exists in the current scene.
 
AudioManager audioManager
 A pointer to the attempt label node if it exists in the current scene.
 
string currentScene
 The name of the current scene.
 
int WINDOW_HEIGHT = 480
 
int WINDOW_WIDTH = 640
 The height of the game window.
 

Detailed Description

Main game application.

Contains the game loop and scene structures.

Constructor & Destructor Documentation

◆ this()

GameApplication::this ( string title,
uint fps )
inline

The width of the game window.

Initialize a new game.

Parameters
titlethe title of the game window.
fpsthe maximum FPS allowed for the game.

Member Function Documentation

◆ AdvanceFrame()

void GameApplication::AdvanceFrame ( )
inline

Take one frame's worth of actions.

Calling this function runs the game loop once.

◆ CheckForLanding()

void GameApplication::CheckForLanding ( )
inline

Checks whether the player will land on an object due to gravity, and restricts its motion if so.

If the player will not hit the ground, take no action. Otherwise, ensure the player will not pass through.

See also
playerNode
ComponentCollision::CheckForFloorCollision

◆ CreateDefaultLevelsMenuScene()

SceneNode GameApplication::CreateDefaultLevelsMenuScene ( )
inline

Create a SceneNode for the level selector menu.

Returns
the newly created scene.
See also
SceneNode

◆ CreateLevelScene()

SceneNode GameApplication::CreateLevelScene ( string level)
inline

Create a SceneNode for a game level.

Parameters
levelthe level name to load.
Returns
the newly created scene.
See also
SceneNode

◆ CreateMenuScene()

SceneNode GameApplication::CreateMenuScene ( )
inline

Create a SceneNode for the main menu.

Returns
the newly created scene.
See also
SceneNode

◆ Input()

void GameApplication::Input ( )
inline

Read and store keyboard and mouse input.

This input can be accessed by IComponent and ComponentScript objects.

See also
GameObject
IComponent
ComponentScript

◆ LoadScene()

void GameApplication::LoadScene ( )
inline

Load the current scene data into the game.

This loads the data from root into the other node pointers.

See also
root

◆ PopScene()

void GameApplication::PopScene ( )
inline

Pop the last scene in the listt off.

See also
scenes

◆ PushScene()

void GameApplication::PushScene ( SceneType scene_type,
string level )
inline

Add a new scene to the list of scenes.

Parameters
scene_typethe type of scene to add.
levelthe name of the scene being added.
See also
scenes

◆ RunLoop()

void GameApplication::RunLoop ( )
inline

Run the game.

This is the entry point into the game. This function runs the game loop on repeat.

◆ UngroundPlayer()

void GameApplication::UngroundPlayer ( )
inline

Marks the player as free falling.

See also
playerNode

◆ Update()

void GameApplication::Update ( )
inline

Update the state of all GameObject components (both IComponent and ComponentScript objects).

  1. Check whether the game is running.
  2. Modify the player's jump velocity so they will land on the ground and not pass through.
  3. Check for collisions with enemy objects.
  4. Update everything else.
  5. Move the camera.
See also
GameObject
IComponent
ComponentScript

◆ UpdateCollisions()

void GameApplication::UpdateCollisions ( )
inline

Checks whether the player hit any enemy objects.

See also
playerNode
ComponentCollision::HandleCollision

◆ UpdateGameIsRunning()

void GameApplication::UpdateGameIsRunning ( )
inline

Check whether the game should continue running.

Updates mGameIsRunning appropriately.

See also
mGameIsRunning

Member Data Documentation

◆ audioManager

AudioManager GameApplication::audioManager

A pointer to the attempt label node if it exists in the current scene.

The AudioManager for the game.


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