JianWei Lee
/
project_game
Meteor defense project
GameEngine/GameEngine.h
- Committer:
- jasper0712
- Date:
- 2017-04-30
- Revision:
- 41:1b396334256b
- Parent:
- 40:3a0c66a0e10e
- Child:
- 43:acbed608a8df
File content as of revision 41:1b396334256b:
#ifndef GAMEENGINE_H #define GAMEENGINE_H #include "mbed.h" #include "N5110.h" #include "Gamepad.h" #include "Weapon.h" #include "Spawn.h" #include "GUI.h" #define Rows 48 #define Cols 84 struct Array { //int array to store the spawn health int Arr[Cols][Rows]; //char array to differentiate the 4 different kind of spawn A, B, C and D&E. char cArr[Cols][Rows]; }; class GameEngine { public: GameEngine(); ~GameEngine(); /**Initialise GameEngine * *Set the number of life at every level to 3 *To initialise all the variables of Weapons and Spawns *@param w - the current number level */ void init(int w); /**Update game * *This is where all the gameplay is gathered *The only way to lose this game is when the spawns reaches the player side (y = 46) for 3 times in a wave *Lights up LEDs according to number of lifes left */ void update(Gamepad &pad, N5110 &lcd); /**Weapon Upgrades * *Weapon upgrade will happen everytime after completing a game wave *This function connects class GUI and Weapons to display weapon levels and confirm upgrades */ void weapUpgrade(Gamepad &pad, N5110 &lcd); /**Starting Menu * *Few strings to be printed on the lcd before starting the game *Light up LEDs in a knight rider pattern */ void startingMenu(Gamepad &pad, N5110 &lcd); /**Update retry.Arr & retry.cArr * *retry.Arr and retry.cArr is always updated at the start of a wave. *To make a copy of the main array */ void update_MainToRetry(); /**Update main array using retry array * *this function will be used when player decided to retry the game */ void update_RetryToMain(); /**Reset the game * *Only thing requires reset is the array and weapon's variables */ void reset_Game(); int doneUpgrade_flag; int retry_flag; int gameMenu_flag; //Main and secondary array required to allow the spawn move and to take damage Array main; Array scnd; //Retry array - when player press retry this array will be used Array retry; private: //declare class with their name Weapon weap; Weapon _d1; Weapon _d2; Spawn spa; GUI _gui; int drawit; int ledNumber; int NumberOfLife; int fireInTheHole_flag; //Turn on LEDs //Number of LEDs that light up will depends on number of lifes left void numberOfLife_leds(Gamepad &pad); //Draw spawn //This is where summon spawn, moving spawn and update array happens. void drawSpawn(N5110 &lcd); //Laser and cannon //This function puts laser and cannon together because cannon can only fire when laser is switched on void laser_and_cannon(Gamepad &pad, N5110 &lcd); //Game Rule //The only way to lose this game is when the spawns reaches the player side (y = 46) for 3 times in a wave void checkGameRule(Gamepad &pad, N5110 &lcd); //Bomb and Shield //This function puts bomb and shield together to prevent double click void bomb_And_Shield(Gamepad &pad, N5110 &lcd); //Update array //After a loop in the game, the main array will be updated using the secondary array void updateArray(); void gameOver(Gamepad &pad, N5110 &lcd); }; #endif