Henry Triff / Mbed 2 deprecated ELEC2645_Project_el18ht

Dependencies:   mbed

Revision:
16:17f91f51358f
Parent:
11:7b12992156de
Child:
22:9065c457a45d
--- a/Ghost/Ghost.h	Sat Mar 28 12:05:27 2020 +0000
+++ b/Ghost/Ghost.h	Sat Mar 28 12:41:25 2020 +0000
@@ -13,6 +13,14 @@
 #include "Ghost.h"
 #include <string>
 
+/** Ghost Class
+* @brief Records the current position of the player so that it can be played back later during ghost mode.
+* @brief The best race (so far) is copied to the SD card when the race is over.
+* @brief Before each race, the previos best ghost data is read from the SD card to internal memory to allow the game to run faster.
+* @author Henry W Triff
+* @date Mar, 2020
+*/
+
 #ifndef STRUCTS
 #define STRUCTS
 
@@ -80,21 +88,54 @@
 {
 public:
 
-    void Record(Point_2D position, int race_time);
-    void Copy(int race_time, int track, int car, SDFileSystem &SD);
-    Point_2D Play(bool ghost_available, int race_time);
-    bool SD_init(SDFileSystem &SD);
-    void SD_Write(int track, int car, int race_time, SDFileSystem &SD);
+    /** Constructor */
+    Ghost();
+    
+    /** Destructor */
+    ~Ghost();
+    
+    /** Formats the SD card with the correct text files and fills them with temporary data.
+    * @param SD The object for the SDFileSystem class (object).
+    */
+    void SD_init(SDFileSystem &SD);
+    
+    /** Copies the ghost data int the txt file associated with the track-car combination to RAM
+    * @param track The user selected track (int)
+    * @param car The user selected car (int)
+    * @param SD The object for the SDFileSystem class (object)
+    */
     void SD_Read(int track, int car, SDFileSystem &SD);
     
+    /** Adds the current position of the car to a Ghost_Data array
+    * @param position The current coordinate position of the players car (Point_2D)
+    * @param race_time The current number of frames elapsed during race
+    */
+    void Record(Point_2D position, int race_time);
+    
+    /** If the race that was just run was faster than previos races, this copies the data in the Ghost_Data array to the SD card
+    * @param race_time The number of frames elapsed during race
+    * @param track The user selected track (int)
+    * @param car The user selected car (int)
+    * @param SD The object for the SDFileSystem class (object)
+    */
+    void Copy(int race_time, int track, int car, SDFileSystem &SD);
+    
+    /** Returns the position of the ghost for a given race_time
+    * @param ghost_available Is the game in ghost mode (bool)
+    * @param race_time The current number of frames elapsed during race (int)
+    * @return Current position of the ghost
+    */
+    Point_2D Play(bool ghost_available, int race_time);
+
+private:
+    
+    void SD_Write(int track, int car, int race_time, SDFileSystem &SD);
     void SD_Write_Data(string name, int race_time, SDFileSystem &SD);
     void SD_Write_Time(int track, int car, int race_time, SDFileSystem &SD);
     void SD_Read_Data(string name, int race_time, SDFileSystem &SD);
     void SD_Read_Time(int track, int car, SDFileSystem &SD);
     int SD_Get_Time(int track, int car, SDFileSystem &SD);
 
-private:
-
 };
 
 #endif
\ No newline at end of file