Arturs Kozlovskis / Mbed 2 deprecated ELEC2645_Project_el18ak

Dependencies:   mbed

Revision:
21:32429d8e90ff
Parent:
15:3f558f8b54ea
Child:
22:f1811602a817
--- a/My_game_clases/Functions.h	Sat May 09 10:53:46 2020 +0000
+++ b/My_game_clases/Functions.h	Tue May 12 15:12:59 2020 +0000
@@ -7,6 +7,13 @@
 #include "Gamepad.h"
 #include "Objects.h"
 
+/**Function class
+* @brief Contains the game engine
+* @author Arturs Kozlovskis
+* @date April,2020
+*/
+
+//holds parabolic ball values
 struct Ball{
     int ball_x_pos[10]; // balls x position
     float movement_y_counter[10]; //sets the gravity with which the ball will fall
@@ -15,11 +22,10 @@
     int time_incrementer[10];//increments time value
     int ball_x_incrementer[10];//increments movement_x_pos value
     int delta_r[10]; // defines the ball size    
-    int ball_trajectory_width[10];
-    
-    
-    
+    int ball_trajectory_width[10]; 
 };
+
+//holds linear ball vvalues
 struct Ball_linear{
     int ball_x_pos[10]; // moves the ball across the screen
     int movement_y_counter[10]; //sets the gravity with which the ball will fall
@@ -27,36 +33,93 @@
     int time_incrementer[10];//increments time value
     int ball_x_incrementer[10];//increments movement_x_pos value
     int delta_r[10]; // defines the ball size    
-    
-    
 };
 
 class Functions 
 {
 public:
+    /**Constructor*/
     Functions();
+    
+    /** Draw parabolic ball
+    * @param N5110 class object
+    * @param Object class object
+    * @param chosen ball(int)
+    */
     void ball_position_parabolic( N5110 &lcd, Objects &objects, int c);//governs the balls movement in a parabolic way
+   
+     /** Draw linear ball
+    * @param N5110 class object
+    * @param Object class object
+    * @param chosen ball(int)
+    */
     void ball_position_linear (N5110 &lcd, Objects &objects, int c);//governs the balls movement in a linear way
+    
+    /** Check for collisions
+    * @param N5110 class object
+    * @param Object class object
+    */
     void collision_checker(N5110 &lcd,Objects &objects);//checks if the shot has coma into contact with the ball
+    
+    /** Find the collided ball(linear)
+    * @param x value of pixel that cause the collision
+    * @param y value of pixel that cause the collision
+    */
     void ball1_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(linear)
+    
+    /** Find the collided ball(parabolic)
+    * @param x value of pixel that cause the collision
+    * @param y value of pixel that cause the collision
+    */
     void ball_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(parabolic)
+    
+    /**Check if cannon has been hit
+    * @param N5110 class object
+    * @param Object class object
+    * @return if collision has happened(bool)
+    */
     bool cannon_smash(N5110 &lcd,Objects &objects);// checks if the cannon has crashed with anything
+    
+    /** Generate a random value
+    * @param Gamepad class object
+    * @return the random value(int)
+    */
     int random(Gamepad &pad);//generates a random number
+    
+    /**Govern the linear ball movement and creation
+    * @param N5110 class object
+    * @param Object class object
+    * @param Gamepad class object
+    */
     void ball_creater_linear(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement equations
+    
+     /**Govern the parabolic ball movement and creation
+    * @param N5110 class object
+    * @param Object class object
+    * @param Gamepad class object
+    */
     void ball_creater_parabolic(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement
+    
+    /**Round a value 
+    * @param the number that needs rounding
+    * @return rounded value
+    */
     int round(float number); //rounds a number
+    
+    /**Get score
+    * @return the current score
+    */
     int get_score();//gets the players score
     
-    vector <int> created_balls;//holds linear balls
-    vector <int> created_ball;//holds the parabolic balls
-    
-
 private:
+    //variables
     int _initial_radiuss;//holds the intial ball radiuss which is 2
     int _cannon_y_pos; // holds the cannons y position
     int _score;//holds the score
-    int _counter;
-    int _previous;
-    int _now;
+    int _counter;//checks if the parabolic ball has to go up or down
+    int _previous; //the previous parabolic x value
+    int _now;// the current parabolic x value
+    vector <int> created_balls;//holds linear balls
+    vector <int> created_ball;//holds the parabolic balls
 };
 #endif
\ No newline at end of file