Dependencies:   MMA8452 N5110 PowerControl beep mbed

Revision:
9:522f9311ff4b
Parent:
8:aebb468546c5
--- a/Game.h	Sat May 09 22:59:15 2015 +0000
+++ b/Game.h	Sun May 10 17:21:39 2015 +0000
@@ -1,8 +1,9 @@
 /**
 @file Game.h
-
 @brief Header file of the game rule which contain member functions, variables and functions definition
-
+@brief Revision 1.0
+@author Huynh Minh Tuan Le
+@date April 2015
 */
 
 #ifndef GAME_H
@@ -13,55 +14,57 @@
 #include "N5110.h"
 #include "Clock.h"
 
-Ticker gatimer;
-int gatimerFlag = 0;
+
+Ticker gatimer; ///< Set a ticker for the game timing
+int gatimerFlag = 0; ///< Declare game ISR flag as a integer type variable
 
 void gatimerExpired()
 {
-    gatimerFlag = 1; //Set flag for timer of the game
+    gatimerFlag = 1; ///Set flag for timer of the game
 }
 
+///Game Class
 class Game
 {
 private:
     /**
-    * @param The acceleration variable recalled from MMA8452.h
+    * The acceleration variable recalled from MMA8452.h
     */
-    Acceleration accel; // Acceleration variable declared in MMA8452 class
+    Acceleration accel; ///Acceleration variable declared in MMA8452 class
 
 public:
     /**
-    * A function that contains condition of easy mode
-    * The conditions: Threshold value of 2g - Time interval for reading data of 0.1s
+    * A function that contains condition of easy mode.
+    * The conditions: Threshold value of 2g - Time interval for reading data of 0.1s.
     */
     void easyMode();
     /**
-    * A function that contains condition of normal mode
-    * The conditions: Threshold value of 3g - Time interval for reading data of 0.2s
+    * A function that contains condition of normal mode.
+    * The conditions: Threshold value of 3g - Time interval for reading data of 0.2s.
     */
     void norMode();
     /**
-    * A functionthat contains condition of hard mode
-    * The conditions: Threshold value of 3g - Time interval for reading data of 0.4s
+    * A functionthat contains condition of hard mode.
+    * The conditions: Threshold value of 3g - Time interval for reading data of 0.4s.
     */
     void hardMode();
     /**
-    * @param A global variable to store play score.
-    * @param This score will later transfer into an array
+    * A global variable to store play score.
+    * This score will later transfer into an array.
     */
     int score;
     /**
-    * @param An array to store set of scores
-    * @param The array structure is as follow:
-    * @param Easy high score, Easy current score, Normal high score, Normal current score, Hard high score, Hard current score.
+    * An array to store set of scores.
+    * The array structure is as follow:
+    * Easy high score, Easy current score, Normal high score, Normal current score, Hard high score, Hard current score.
     */
     int scoArr[6];
     /**
-    * A function used to reset the game condition
+    * A function used to reset the game condition.
     */
     void reset();
     /**
-    * A funtion to draw a battery image when playing game
+    * A funtion to draw a battery image when playing game.
     */
     void battImag();
 };
@@ -83,11 +86,11 @@
             battImag();
         }
     }
-
-    scoArr[1] = score;
-    if(scoArr[0] > scoArr[1]) {
+    //Condition for storing "score" and transferring "score" between scoArr elements. 
+    scoArr[1] = score; //Store "score" variable into 2nd element of scoArr array
+    if(scoArr[0] > scoArr[1]) { //If 1st element is greater than 2nd element, store in 2nd element
         scoArr[1] = score;
-    } else if(scoArr[0] < scoArr[1]) {
+    } else if(scoArr[0] < scoArr[1]) { //Vice versa, store in 1st element
         scoArr[0] = score;
     }
 }
@@ -109,10 +112,11 @@
             battImag();
         }
     }
-    scoArr[3] = score;
-    if(scoArr[2] > scoArr[3]) {
+    //Condition for storing "score" and transferring "score" between scoArr elements.
+    scoArr[3] = score; //Store "score" variable into 4th element of scoArr array
+    if(scoArr[2] > scoArr[3]) { //If 3rd element is greater than 4th element, store in 4th element
         scoArr[3] = score;
-    } else if(scoArr[2] < scoArr[3]) {
+    } else if(scoArr[2] < scoArr[3]) { //Vice versa, store in 3rd element
         scoArr[2] = score;
     }
 }
@@ -134,10 +138,11 @@
             battImag();
         }
     }
-    scoArr[5] = score;
-    if(scoArr[4] > scoArr[5]) {
+    //Condition for storing "score" and transferring "score" between scoArr elements.
+    scoArr[5] = score; //Store "score" variable into 6th element of scoArr array
+    if(scoArr[4] > scoArr[5]) { //If 5th element is greater than 6th element, store in 6th element
         scoArr[5] = score;
-    } else if(scoArr[4] < scoArr[5]) {
+    } else if(scoArr[4] < scoArr[5]) { //Vice versa, store in 5th element
         scoArr[4] = score;
     }
 }