Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Revision:
92:693a6ae0ff8e
Parent:
87:871d9fecb593
Child:
95:b068b0735f45
--- a/GameEngine/SnakevsBlock/SnakevsBlock.h	Wed May 08 21:29:06 2019 +0000
+++ b/GameEngine/SnakevsBlock/SnakevsBlock.h	Wed May 08 22:27:45 2019 +0000
@@ -15,188 +15,188 @@
 #include "Stats.h"
 #include "SDFileSystem.h"
 
+/** SnakevsBlock Class
+@brief This class controls the game by detecting collisions, drawing objects and updating game parameters.
+@author Ahmed N.Adamjee
+@date 8th May 2019
+*/
 class SnakevsBlock
 {
 public:
+    /** Constructor */
     SnakevsBlock();
+    /** Destructor */
     ~SnakevsBlock();
 
     /** Initialise Game Machine
     *
     *   This function initialises the game machine.
     */
+    /** 
+    * @brief Initialises all game parameters and objects and therefore configures the start state of the game.
+    * @param N5110 *lcd @details pointer to the N5110 object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.
+    * @param Gamepad *pad @details pointer to the gamepad object in main, address of this pointer is saved to make availability to the entire class, without passing address to each function.
+    */
     void init(N5110 *lcd, Gamepad *pad);
 
-    /** Reset Game Machine
-    *
-    *   This function prepares the game machine for the next level.
+    /**
+    * @brief This function prepares the game machine for the next level.
     */
     void reset( );
 
-    /** Initialise objects
-    *
-    *   This function initialises the objects that are used to functionalise the game.
+    /**
+    * @brief This function initialises the objects that are used to functionalise the game.
     */
     void object_initialisations();
 
-    /** Read Input
-    *
-    *   This function obtains numeric data from the gamepads joystick.
+    /**
+    *  @brief This function obtains numeric data from the gamepads joystick.
+    *  @param FXOS8700CQ &device @details The FXOS8700CQ library.
+    *  @parm g_mode @details Contains a value that is used to choose between setting the controls based on joystick or motion control.
     */
-    void read_input(FXOS8700CQ &device, int gm);
+    void read_input(FXOS8700CQ &device, int g_mode);
 
-    /** Calculate Tilt
-    *
-    *   This function reads the angle of tilt required for motion contol and also processes it by reseting the angle buffer if A is pressed.
+    /**
+    *  @brief This function reads the angle of tilt required for motion contol and also processes it by reseting the angle buffer if A is pressed.
+    *  @param FXOS8700CQ &device @details The FXOS8700CQ library.
     */
     void calculateTilt(FXOS8700CQ &device);
 
-    /** Light The LEDS
-    *
-    *   This function ligths the LEDS dependent on the direction of travel.
+    /**
+    * @brief This function ligths the LEDS dependent on the direction of travel.
     */
     void lightTheLEDS();
 
-    /** Update Snake Length And Movement
-    *
-    *   This function updates length and motion data inside the snake class and also uses the length manager class to update length.
+    /**
+    * @brief This function updates length and motion data inside the snake class and also uses the length manager class to update length.
     */
     void updateSnakeLengthAndMovement();
 
-    /** Draw
-    *
-    *   This function contains the draw functions of the other libraries used in the game.
+    /**
+    * @brief This function contains the draw functions of the other libraries used in the game.
     */
     void draw();
 
-    /** Update
-    *
-    *   This function contains the update functions of the other libraries used in the game.
+    /**
+    * @brief This function contains the update functions of the other libraries used in the game.
     */
     void update();
 
-    /** Check Game Progression
-    *
-    *   Function handles level progression and level failure operations by using the class WinLoose.
+    /**
+    * @brief Function handles level progression and level failure operations by using the class WinLoose.
+    * @param SDFileSystem &sd @details The SDFileSystem library.
     */
     int CheckGameProgression(SDFileSystem &sd);
 
-    /** Get Position
-    *
-    *   This function contains the Get Position functions of the otehr libraries used in the game.
+    /**
+    * @brief This function contains the Get Position functions of all the class objects used in the game and saves them to use in an array throughout the class.
     */
     void get_pos();
 
-    //Gamepad @enginePad
-
 private:
 
-    /** Check for Snake and Food collision
-    *
-    *   This function checks if the Snake has come into contact with it's food.
+    /**
+    *@brief This function checks if the Snake has come into contact with it's food.
     */
     void CheckSnakeFoodCollision();
 
-    /** Check Snake Food Y Collision
-    *
-    *   This function automatically detects each combination of collision in the y postion.
+    /**
+    * @brief This function automatically detects each combination of collision in the y postion.
+    * @param food_sr @details creted in a loop that runs 3 times to detect collision with all the three food objects.
     */
     void CheckSnakeFoodYCollision(int food_sr);
 
-    /** Check Snake Food X Collision
-    *
-    *   This function automatically detects each combination of collision in the x postion.
+    /**
+    * @brief This function automatically detects each combination of collision in the x postion.
+    * @param food_sr @details creted in a loop that runs 3 times to detect collision with all the three food objects.
     */
     void CheckSnakeFoodXCollision(int food_sr);
 
-    /** Implement Snake Food Collision
-    *
-    *   This function automatically detects which food we are interacting with and increases the snake length accordingly.
+    /**
+    * @brief This function automatically detects which food we are interacting with and increases the snake length accordingly.
+    * @param food_sr @details creted in a loop that runs 3 times to detect collision with all the three food objects.
     */
     void ImplementSnakeFoodCollision(int food_sr);
 
-    /** Check for Snake and Block collision
-    *
-    *   This function checks if the Snake has come into contact with any Block.
+    /**
+    * @brief This function checks if the Snake has come into contact with any Block.
     */
     void CheckSnakeBlockCollision();
+    
+    /**
+    * @brief This function returns the srn of the block we are colliding with.
+    * @param Block @details value of int block which is compared to a preset ranges, to allocate a serial number to the colliding block.
+    */
+    int CheckBlock(int Block);
 
-    /** Implement velocity alteration.
-    *
-    *   this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.lock.
+    /**
+    * @brief this is to stop/move the background (food and blocks), when collision occurs at a length greater than 10.lock.
+    * @param srn @details this is the serial number of blocks and tells us which of the 5 blocks we are colliding with
     */
     void _setVelocity(int srn);
 
-    /** Check Block
-    *
-    *   This function returns the srn of the block we are colliding with;
-    */
-    int CheckBlock(int Block);
-
-    /** Implement Collision
-    *
-    *   This function allows the appropriate maths to take place after every collision.
+    /**
+    * @brief This function allows the appropriate maths to take place after every collision.
     */
     void ImplementSnakeBlockCollision();
 
-    /** Check for Snake and Block Sides collision
-    *
-    *   This function checks if the Snake has come into contact with any the sides of the block and stops it moving.
+    /**
+    * @brief This function checks if the Snake has come into contact with any the sides of the block and stops it moving.
     */
     void CheckSnakeBlockSidesCollision();
 
-    /** Make Default Motion Free
-    *
-    *   This function makes the default motion of the snake freemoving before a collision is checked for, to forget the previous collision.
+    /**
+    * @brief This function makes the default motion of the snake freemoving before a collision is checked for, to forget the previous collision.
     */
     void MakeDefaultMotionFree();
 
-    /** Check Collision in Y axis
-    *
-    *   This function checks if the Snake and blocks collide anywhere in the Y axis.
+    /**
+    * @brief This function checks if the Snake and blocks collide anywhere in the Y axis.
+    * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length.
     */
     void CheckSnakeBlockSidesYCollision(int i);
 
-    /** Check Collision in X axis
-    *
-    *   This function checks if the Snake and blocks collide anywhere in the X axis.
+    /**
+    * @brief This function checks if the Snake and blocks collide anywhere in the X axis.
+    * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length.
     */
     void CheckSnakeBlockSidesXCollision(int i);
 
-    /** Check Block sides Collision is East or West
-    *
-    *  checks if the colliding wall is on east side or west side and then calls ImplementBarrierCollision(i) to carry out the required task.
+    /**
+    * @brief Checks if the colliding wall is on east side or west side and then calls ImplementBarrierCollision(i) to carry out the required task.
+    * @param X @details is just the X axis coordinate of the nokia screen.
+    * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length.
     */
     void CheckSnakeBlockSidesEastWestCollision(int X, int i);
 
-    /** Check for Snake and Barrier collisions.
-    *
-    *   This function checks if the Snake has come into contact with any the sides of the barriers and stops it moving in the X axis if true.
+    /**
+    * @brief This function checks if the Snake has come into contact with any the sides of the barriers and stops it moving in the X axis if true.
+    * @param bar_sr_no @details is the index of which barrier collision we are detecting.
     */
     void CheckSnakeBarrierCollision(int bar_sr_no);
 
-    /** Check Collision in Y axis
-    *
-    *   This function checks if the Snake and blocks collide anywhere in the Y axis.
+    /**
+    * @brief This function checks if the Snake and blocks collide anywhere in the Y axis.
+    * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length.
+    * @param bar_sr_no @details is the index of which barrier collision we are detecting.
     */
     void CheckSnakeBarrierYCollision(int i, int bar_sr_no);  //i is the index of the snake beed and checks for all possible collisions with the snake respective to it's length.
     
-    /** Check Barrier Collision is East or West
-    *
-    *  checks if the colliding barrier's side is on east side or west side of snake and then calls ImplementBarrierCollision(i) to carry out the required task.
+    /**
+    * @brief Checks if the colliding barrier's side is on east side or west side of snake and then calls ImplementBarrierCollision(i) to carry out the required task.
+    * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length.
+    * @param bar_sr_no @details is the index of which barrier collision we are detecting.
     */
     void CheckSnakeBarrierEastWestCollision(int i, int bar_sr_no); //i checks for all possible collisions with the snake respective to it's length.
 
-    /** Make Virtual Length Max Ten
-    *
-    *  This makes the virtual length -> 10 for the side collision implementation because if the length is fifteen and the last beed collides, it still is the 10th beed
-    *  on screen.
+    /**
+    * @brief This makes the virtual length -> 10 for the side collision implementation because if the length is fifteen and the last beed collides, it still is the 10th beed on screen.
     */
     void makeVirtualLengthMaxTen();
 
-    /** Stop X Axis Motion
-    *
-    *   This function implements the sides collision by making the x axis speed of the particular snake beed 0.
+    /**
+    * @brief This function implements the sides collision by making the x axis speed of the particular snake beed 0.
+    * @param i @details is the index of the snake beed and allows to check for all possible collisions with the snake respective to it's length.
     */
     void ImplementBarrierCollision(int i);