![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
contains my game for the embedded systems project 2645
Dependencies: mbed FXOS8700CQQQ
GameEngine/RocketRacer.h
- Committer:
- OmarAlebiary
- Date:
- 2019-04-09
- Revision:
- 19:ad9dc8e418c9
- Parent:
- 17:989ff25612ad
- Child:
- 22:3e6ff378d651
File content as of revision 19:ad9dc8e418c9:
#ifndef ROCKETRACER_H #define ROCKETRACER_H #include "mbed.h" #include "N5110.h" #include <cstdlib> #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); // 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(); /** * @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); private: int first_enemy_position; int second_enemy_position; int enemy_phase; int game_speed; int score; char Init_position; bool enemy_dead; bool control; }; #endif