ELEC2645 (2018/19) / Mbed 2 deprecated el17arm

Dependencies:   mbed

Revision:
46:de3462ad5aef
Parent:
45:bad704c546d4
Child:
47:3425159c0211
--- a/Gameengine/Gameengine.h	Wed Apr 24 13:17:58 2019 +0000
+++ b/Gameengine/Gameengine.h	Wed Apr 24 14:24:56 2019 +0000
@@ -8,9 +8,11 @@
 #include "Levels.h"
 
 /** Gameengine Class
+@brief Builds all levels and sets all default values. Updates all game settings 
+and contains functions for all game conditions
+
 @author Andrew Milner University of Leeds
-@brief Builds all levels and sets all default values. Updates all game settings
-and contains functions for all game conditions
+
 @date April 2019
 */ 
 
@@ -21,28 +23,108 @@
 
     Gameengine();
     ~Gameengine();
-  /** 
-  * @brief Reads direction the player is moving
-  * @details Uses getdirection() function from Gamepad library
+ /** 
+  * @brief Initialises all default game settings.
+  * @details Sets player starting position, number of lives, level start and timer.
+  */
+    void game_init();
+ /** 
+  * @brief updates all game game settings.
+  * @details Contains all functions that .
+  */
+    void update(N5110 &lcd, Gamepad &pad);
+ /** 
+  * @brief updates and renders all level objects for level 1.
+  */
+    void draw_l1(N5110 &lcd, Gamepad &pad);
+ /** 
+  * @brief updates and renders all level objects for level 2.
+  */
+    void draw_l2(N5110 &lcd, Gamepad &pad);
+ /** 
+  * @brief updates and renders all level objects for level 3.
+  */
+  
+    void draw_l3(N5110 &lcd, Gamepad &pad);
+ /** 
+  * @brief Reads direction the player is moving.
+  * @details Uses getdirection() function from Gamepad library.
   */
     void read_direction(Gamepad &pad);
-    void update(N5110 &lcd, Gamepad &pad);
-    void game_init();
-    void draw_l1(N5110 &lcd, Gamepad &pad);
-    void draw_l2(N5110 &lcd, Gamepad &pad);
-    void draw_l3(N5110 &lcd, Gamepad &pad);
+ /** 
+  * @brief Calculates lives remaining.
+  * @returns integer calue to control lives fsm state in leds() main.cpp
+  */
+    int oxygen_leds();
+ /** 
+  * @brief Calculates time remaining.
+  * @details Calculates time remaining, every 1/3 of total time passed the return 
+  * value changes.
+  * @return integer value to control oxygen fsm state in leds() main.cpp
+  */
+    int lives_leds();
+ /** 
+  * @brief Calculates and displays player score.
+  * @details At game over or game completed the players score is calculated and
+  * displayed. It takes time remaining and multiplies this by lives remaining, then 
+  * adds on 10 points for every key collected.
+  */ 
+    void get_score(N5110 &lcd);
+/** 
+  * @brief Returns true if game completed.
+  * @details calculates when _level variable has gone beyond number of levels in game.
+  * @return true if game complete
+  */ 
+    bool game_complete(N5110 &lcd);
+
+ /** 
+  * @brief Reduces number of lives on player death.
+  * @details After reducing lives, makes tone to signify player death, resets player
+  * back to start, creates small pause so gameplay is slightly paused.
+  */
     void lose_life(Gamepad &pad, N5110 &lcd);
+ /** 
+  * @brief States whether game over condition met
+  * @return returns true if game over.
+  */
     bool game_over();
+ /** 
+  * @brief Function returns true when player at exit.
+  * @details Function returns true when the player is in contact with the level exit.
+  */
+    bool level_exit(N5110 &lcd);
+ /** 
+  * @brief Function returns true when level complete conditions met.
+  * @details Function returns true when all 5 keys have been collected using _sprites.keys_collected()
+  * and player is in contact with the level exit using level_exit() function
+  * The calculates time reamining then resets, resets enemy and key flags
+  * so they can be initialised for the next level, increases _level by 1 so next
+  * level can be drawn, keys needed increased by 5 and miner position reset.
+  */
     void next_level(N5110 &lcd);
+ /** 
+  * @brief Function returns true if player in contact with trap
+  * @details Function sets all trap poisitons and collision rules. Usues int i
+  * to select which level positions to use.
+  */
     bool trap_death(N5110 &lcd);
+ /** 
+  * @brief Function returns true if player in contact with trap.
+  * @details Function sets all trap positons and collision rules stated in
+  * Sprites class. Uses int i to select which level positions to use, these are
+  * specified in Level class.
+  */
     void key_draw(N5110 &lcd,Gamepad &pad);
+ /** 
+  * @brief Function sets all block positions and collision rules.
+  * @details Function sets all block positons and collision rules stated in
+  * Sprites class. Keys are indexed so each one is treated independently
+  * otherwise all will disappear if one is collected. Uses int i to select which
+  * level positions to use, these are specified in Level class
+  */
     void blocks(N5110 &lcd);
     bool enemies(N5110 &lcd);
     void key_reinit();
-    int oxygen_leds();
-    int lives_leds();
-    void get_score(N5110 &lcd);
-    bool game_complete(N5110 &lcd);
 
 private:
     
@@ -56,7 +138,6 @@
     bool _enem_flag;
     int _five_keys;
     bool _key_reinit;
-    bool level_exit(N5110 &lcd);
     int _oxy_state;
     int _life_state;
     float _total_time;