![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Meteor defense project
Diff: GameEngine/GameEngine.h
- Revision:
- 40:3a0c66a0e10e
- Parent:
- 38:c66a69c1a6de
- Child:
- 41:1b396334256b
--- a/GameEngine/GameEngine.h Tue Apr 25 22:26:14 2017 +0000 +++ b/GameEngine/GameEngine.h Sat Apr 29 19:27:20 2017 +0000 @@ -11,6 +11,13 @@ #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 { @@ -18,30 +25,63 @@ public: GameEngine(); ~GameEngine(); - void drawSpawn(N5110 &lcd); - void laser_and_bomb(Gamepad &pad, N5110 &lcd); - void checkGameRule(Gamepad &pad, N5110 &lcd); - void gameWave(); //not yet started - void bombAndShield(Gamepad &pad, N5110 &lcd); - void updateArray(); - + + /**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); - void numberOfLife_leds(Gamepad &pad); + + /**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(); int doneUpgrade_flag; + int retry_flag; + int gameMenu_flag; - int Array[Cols][Rows]; //main - int Array2[Cols][Rows]; // secondary - //this char array to differentiate the 4 different kind of spawn - a, b, c and d. - char charArray[Cols][Rows]; //used as main array - char charArray2[Cols][Rows]; //secondary array - + //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; @@ -51,8 +91,36 @@ int drawit; int ledNumber; int NumberOfLife; + int fireInTheHole_flag; - 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); + };