Reham Faqehi / Mbed 2 deprecated fy15raf

Dependencies:   mbed

Fork of fy15raf by ELEC2645 (2017/18)

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GameEngine.h Source File

GameEngine.h

00001 #ifndef GameEngine_H
00002 #define GameEngine_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 #include "Spaceship.h"
00008 #include "Asteroid.h"
00009 
00010 /** GameEngine Class
00011 * @brief class to control the game functions 
00012 * @author Reham Faqehi  
00013 * @date May, 2018  */ 
00014 
00015 class GameEngine
00016 {
00017 
00018 public:
00019     /** Constructor */ 
00020     GameEngine();
00021     
00022     /** Destructor */ 
00023     ~GameEngine();
00024 
00025     /** Initialise the game elements: 
00026     * Spaceship, asteroids, time, and 
00027     * game over value             
00028     */   
00029     void init();
00030     
00031     /** Read the direction and magnitude 
00032     * data from the joystick 
00033     * @param gamepad object (Gamepad) 
00034     */ 
00035     void read_input(Gamepad &g_pad);
00036     
00037     /** Draw the game elements: 
00038     * Spaceship, asteroids, hearts
00039     * and show the time 
00040     * @param LCD object (N5110) 
00041     */ 
00042     void draw(N5110 &lcd);
00043     
00044     /** Update the game elements: 
00045     * Spaceship, asteroids, the hearts
00046     * and the time 
00047     * @param gamepad object (Gamepad)
00048     */
00049     void update(Gamepad &pad);
00050     
00051     /** Draw the hearts
00052     * @param LCD object (N5110) 
00053     */ 
00054     void draw_hearts(N5110 &lcd);
00055     
00056     /** Check if it is the end of the game
00057     * @return the gameover value (int) 
00058     */
00059     int check_gameOver();
00060     
00061     /** Print the current time in sec
00062     * @param LCD object (N5110) 
00063     */
00064     void print_time(N5110 &lcd);
00065     
00066     /** Increase the time every 1 sec
00067     */
00068     void time_increment();
00069     
00070     /** Stop the time counter at 
00071     * the end of the game
00072     */
00073     void time_stop();
00074     
00075     /** Print the total time in sec
00076     * at the end of the game
00077     * @param LCD object (N5110) 
00078     */
00079     void print_travel_time(N5110 &lcd);
00080     
00081     /** Reset the time and 
00082     * game over value to play again
00083     */
00084     void reset_gameOver();
00085     
00086 
00087 private:
00088 
00089     /** Check the collision with Asteroid 1
00090     * @param gamepad object (Gamepad)
00091     */
00092     void check_collision1(Gamepad &pad);
00093     
00094     /** Check the collision with Asteroid 2
00095     * @param gamepad object (Gamepad)
00096     */
00097     void check_collision2(Gamepad &pad);
00098     
00099     /** Check the collision with Asteroid 3
00100     * @param gamepad object (Gamepad)
00101     */
00102     void check_collision3(Gamepad &pad);
00103         
00104     int gameOver;
00105     Spaceship _Spaceship;
00106     Asteroid _asteroid1;
00107     Asteroid _asteroid2;
00108     Asteroid _asteroid3;
00109     Direction _d;
00110     float _mag;
00111     Timer time;
00112     int _time;
00113 
00114 };
00115 
00116 #endif