Dmitrijs Griskovs / Mbed 2 deprecated el17dg

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Game Class Reference

Game Class Reference

Game Class. More...

#include <game.h>

Public Member Functions

 Game ()
 Constructor.
bool updateAndDraw ()
 The main game function where all the gameplay and rendering happens.
void startNewGame ()
 Resets all the in game variable when new game begins.
bool forceShildActivate ()
 Check whether the button R was pressed or not to turn ON/OFF the shield.

Detailed Description

Game Class.

Stores general game logic.

Author:
Dmitrijs Griskovs
Date:
15/04/2019

Definition at line 26 of file game.h.


Constructor & Destructor Documentation

Game (  )

Constructor.

It is crucial to init game_over to true, so it calls startNewGame on the first update.

Definition at line 33 of file game.h.


Member Function Documentation

bool forceShildActivate (  )

Check whether the button R was pressed or not to turn ON/OFF the shield.

When the button R is pressed it sets bool "is_shield_active" to its opposite value. If the shield is active then, a ship with force shield sprite is drawn and the player's ability to shoot deactivates.

Definition at line 334 of file game.cpp.

void startNewGame (  )

Resets all the in game variable when new game begins.

This function resets all the values to their intial states when the game is first began when the player dies and wants to restart the game.

This function resets all the values to their intial states when the game is first began when the player dies and wants to restart the game. It does not reset the values when the game is paused.

It does not reset the values when the game is paused.

Definition at line 271 of file game.cpp.

bool updateAndDraw (  )

The main game function where all the gameplay and rendering happens.

This is the main function of game.cpp, where the actual gameplay happens.

This is the main function of game.cpp, where the actual gameplay happens. Here all other functions are activeated, and when the player dies, it returns back to main menu "main.cpp" it also draws all sprites in the game.

Returns:
bool want_to_pause, when "START" button is pressed.

Here all other functions are activeated, and when the player dies, it returns back to main menu "main.cpp".

Definition at line 103 of file game.cpp.