Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: GameEngine/GameEngine.h
- Revision:
- 15:658f1216ee84
- Parent:
- 14:cf4a32245152
- Child:
- 16:106c27d03402
--- a/GameEngine/GameEngine.h Sun May 06 16:17:41 2018 +0000
+++ b/GameEngine/GameEngine.h Mon May 07 13:29:49 2018 +0000
@@ -7,33 +7,101 @@
#include "Rocket.h"
#include "Asteroid.h"
+/** GameEngine Class
+* @brief class to control the game functions
+* @author Reham Faqehi
+* @date May, 2018 */
class GameEngine
{
public:
+ /** Constructor */
GameEngine();
+
+ /** Destructor */
~GameEngine();
+ /** Initialise the game elements:
+ * rocket, asteroids, time, and
+ * game over value
+ */
void init();
+
+ /** Read the direction and magnitude
+ * data from the joystick
+ * @param gamepad object (Gamepad)
+ */
void read_input(Gamepad &g_pad);
+
+ /** Draw the game elements:
+ * rocket, asteroids, hearts
+ * and show the time
+ * @param LCD object (N5110)
+ */
void draw(N5110 &lcd);
+
+ /** Update the game elements:
+ * rocket, asteroids, the hearts
+ * and the time
+ * @param gamepad object (Gamepad)
+ */
void update(Gamepad &pad);
+
+ /** Draw the hearts
+ * @param LCD object (N5110)
+ */
void draw_hearts(N5110 &lcd);
+
+ /** Check if it is the end of the game
+ * @return the gameover value (int)
+ */
int check_gameOver();
+
+ /** Print the current time in sec
+ * @param LCD object (N5110)
+ */
void print_time(N5110 &lcd);
+
+ /** Increase the time every 1 sec
+ */
void time_increment();
+
+ /** Stop the time counter at
+ * the end of the game
+ */
void time_stop();
+
+ /** Print the total time in sec
+ * at the end of the game
+ * @param LCD object (N5110)
+ */
void print_travel_time(N5110 &lcd);
+
+ /** Reset the time and
+ * game over value to play again
+ */
void reset_gameOver();
- int gameOver;
+
private:
+ /** Check the collision with Asteroid 1
+ * @param gamepad object (Gamepad)
+ */
void check_collision1(Gamepad &pad);
+
+ /** Check the collision with Asteroid 2
+ * @param gamepad object (Gamepad)
+ */
void check_collision2(Gamepad &pad);
+
+ /** Check the collision with Asteroid 3
+ * @param gamepad object (Gamepad)
+ */
void check_collision3(Gamepad &pad);
+ int gameOver;
Rocket _rocket;
Asteroid _asteroid1;
Asteroid _asteroid2;