![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
contains my game for the embedded systems project 2645
Dependencies: mbed FXOS8700CQQQ
Diff: GameEngine/RocketRacer.h
- Revision:
- 17:989ff25612ad
- Parent:
- 16:93a8147a4358
- Child:
- 19:ad9dc8e418c9
diff -r 93a8147a4358 -r 989ff25612ad GameEngine/RocketRacer.h --- a/GameEngine/RocketRacer.h Sun Apr 07 21:44:35 2019 +0000 +++ b/GameEngine/RocketRacer.h Sun Apr 07 22:58:15 2019 +0000 @@ -7,24 +7,116 @@ #include <ctime> #include "Gamepad.h" +/** RocketRacer class +@brief C++ class containing the game methods and the interface + +@version 1.0 + +@author Omar Alebiary + +@date April 2019 + +@code + +#include "mbed.h" +#include "N5110.h" +#include "Gamepad.h" +#include "RocketRacer.h" + +// objects +Gamepad pad; +RocketRacer rc; +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +DigitalIn buttonA(PTB9); +// prototypes +void welcome(); +void nextmenu(); +void setup(); + +int main(){ + + + setup(); + welcome(); + nextmenu(); + + + while(1){ + rc.Game_Loop(lcd,pad); + } + + +} + +@endcode +*/ class RocketRacer{ public: + /** + * @brief Default Constuctor + * @param None @details Creates the object of class RocketRacer + */ RocketRacer(); - Gamepad Mypad; + + /** + * @brief method that has all the screen rendering + * @param lcd @details calls the lcd object to draw strings and objects on the display + */ void Main_Game_Display(N5110 &lcd); + /** + * @brief method that dispalys the game over screen with the high score achieved + * @param lcd @details calls the lcd object to draw strings on the display + * @param pad @details calls the Gamepad object to access methods from the Gamepad class + */ void End_Game(Gamepad &pad,N5110 &lcd); + /** + * @brief method that adds difficulty to the game after proceeding each level + * @param pad @details calls the Gamepad object to access methods from the Gamepad class + */ void Game_difficulty(Gamepad &pad); + + /** + * @brief method that generates random enemies + * @param none @details seeds the rand function then generate a random enemies + */ void Generate_New_Enemy(); + /** + * @brief method that checks if the randomly generated enemies crossed the player + * and calls the End_Game method accordingly if they collide else increments the score + * @param lcd @details calls the lcd object to be passed to the End_Game method + * @param pad @details calls the Gamepad object to be passed to the End_Game method + */ void Check_Enemy_Dead(N5110 &lcd,Gamepad &pad); + /** + * @brief method that checks the joystick (and L &R buttons) direction whether its left,right or centre + * and increment or decrement according to the current position + * @param pad @details calls the Gamepad object to access the get_direction method from the Gamepad class + */ void Joystick_position(Gamepad &pad); + /** + * @brief method that has the game loop which calls all the methods(from the same class)for the game to operate + * @param lcd @details calls the lcd object to be passed to the methods called inside this method + * @param pad @details calls the Gamepad object to be passed to the methods called inside this method + */ void Game_Loop(N5110 &lcd,Gamepad &pad); + /** + * @brief method that draws the rocket sprite according to the player position + * @param lcd @details calls the lcd object to access the drawSprite method + * @param RocketPosition @details the position of the rocket + */ void player_position(N5110 &lcd,char RocketPosition); + /** + * @brief method that draws the enemy sprite + * @param lcd @details calls the lcd object to access the drawSprite method + * @param place @details the position of the rocket + * @param phase @details the phase of the rocket + */ void enemy_position(N5110 &lcd,int place, int phase);