Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17dg by
game/game.h
- Committer:
- Noximilien
- Date:
- 2019-04-26
- Revision:
- 32:5403bb974294
- Parent:
- 31:becb8f6bf7b7
- Child:
- 33:c623c6d5ed16
File content as of revision 32:5403bb974294:
#ifndef GAME_H
#define GAME_H
/**
* GameGlobals Class
* @brief Globals that different places in code can modify
* @author Dmitrijs Griskovs
* @date 22/04/2019
*/
class GameGlobals {
public:
static int game_score;
static int score_count_for_difficulty;
static int player_lifes;
static int high_score;
static bool is_shield_on;
};
/**
* Game Class
* @brief Stores general game logic.
* @author Dmitrijs Griskovs
* @date 15/04/2019
*/
class Game{
public:
/**
* Constructor.
* @brief It's crucial to init game_over to true, so it calls
* startNewGame on the first update.
*/
Game() : game_over(true) { }
/**
* @brief The main game function where all the gameplay and rendering happens.
* @details 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.
*/
bool updateAndDraw();
/**
* @brief Resets all the in game variable when new game begins.
* @details 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.
*/
void startNewGame();
/**
* @brief Check whether the button R was pressed or not to turn ON/OFF the shield.
* @details 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.
*/
bool forceShildActivate();
private:
bool checkForGameOver();
void gameOver();
void drawGameOver();
void ifGameOverSkipped();
void ledsGameOver();
void musicGameOver();
void collideEnemiesAndBlasts();
void collideEnemiesBlastsAndPlayer();
void collideEnemiesAndPlayer();
void starsSpawnDelay();
void increaseGameDifficultyAndEnemySpawnDelay();
void printMusicCountersTest();
void lowFrequencyPartMusic();
void highFrequencyPartMusic();
bool returnToMenu();
bool game_over;
int low_frequency_music_counter;
int high_frequency_music_counter;
int enemy_ship_delay_counter;
int enemy_ship_delay_max;
bool led_state;
};
#endif
