![](/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-21
- Revision:
- 27:771d186b1bc8
- Parent:
- 25:7e3b6df93dd5
- Child:
- 28:39607fb67e88
File content as of revision 27:771d186b1bc8:
#ifndef ROCKETRACER_H #define ROCKETRACER_H #include "mbed.h" #include "N5110.h" #include <cstdlib> #include <ctime> #include "Gamepad.h" #include "GameSprites.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; Menus menus; // prototypes void setup(); int main(){ setup(); menus.welcomeMenu(pad,lcd); menus.InstructionsMenu(pad,lcd); //keeps looping untill the player loses while(1){ Rocket_Racer.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); /** * @brief method that plays the gameover melody *@param pad @details calls the Gamepad object to be passed to the method called inside this method */ void End_Game_Melody(Gamepad &pad); 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