Arturs Kozlovskis 201253737

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Functions.h Source File

Functions.h

00001 #ifndef FUNCTIONS_H
00002 #define FUNCTIONS_H
00003 
00004 //includes
00005 #include "mbed.h"
00006 #include "N5110.h"
00007 #include "Gamepad.h"
00008 #include "Objects.h"
00009 
00010 //holds parabolic ball values
00011 /** Struct for parabolic ball's varibales*/
00012 struct Ball{
00013     int ball_x_pos[10]; /**< Holds parabolic ball's x position(int)*/ 
00014     float movement_y_counter[10]; /**< Sets the gravity with which the ball will fall(float)*/
00015     int time[10];/**<Holds the time which is used in the balls movement(int)*/
00016     int ball_y_pos[10];/**<Holds parabolic ball's y position(int)*/
00017     int time_incrementer[10];/**<Increments time value(int)*/
00018     int ball_x_incrementer[10];/**Increments ball's x position(int)*/
00019     int delta_r[10]; /**< Holds ball's radiuss value(int)*/    
00020     int ball_trajectory_width[10];/**<Holds the value of ball's trajectories width(int)*/ 
00021 };
00022 
00023 //holds linear ball vvalues
00024 /**Struct for linear ball's varables*/
00025 struct Ball_linear{
00026     int ball_x_pos[10]; /**< Holds ball's x position(int)*/
00027     int movement_y_counter[10]; /**Sets the gravity with which the ball will fall(int)*/
00028     int ball_y_pos[10];/**<Ball's y position(int)*/
00029     int time_incrementer[10];/**<Increments the y(initaly time) value(int)*/
00030     int ball_x_incrementer[10];/**<Increments ball's x value(int)*/
00031     int delta_r[10];/**< Holds ball's radiuss value(int)*/    
00032 };
00033 
00034 /**Functions class
00035 * @brief Contains the game engine
00036 * @author Arturs Kozlovskis
00037 * @date April,2020
00038 */
00039 class Functions 
00040 {
00041 public:
00042     /**Constructor*/
00043     Functions();
00044     
00045     /** Draw parabolic ball
00046     * @param N5110 class object
00047     * @param Objects class object
00048     * @param Gamepad class object
00049     * @param c tell the function which ball to chose from(int)
00050     */
00051     void ball_position_parabolic( N5110 &lcd, Objects &objects,Gamepad &pad, int c);//governs the balls movement in a parabolic way
00052    
00053      /** Draw linear ball
00054     * @param N5110 class object
00055     * @param Objects class object
00056     * @param Gamepad class object
00057     * @param c tell the function which ball to chose from(int)
00058     */
00059     void ball_position_linear (N5110 &lcd, Objects &objects,Gamepad &pad, int c);//governs the balls movement in a linear way
00060     
00061     /** Check for collisions
00062     * @param N5110 class object
00063     * @param Objects class object
00064     * @param Gamepad class object
00065     */
00066     void collision_checker(N5110 &lcd,Objects &objects,Gamepad &pad);//checks if the shot has coma into contact with the ball
00067     
00068     /** Find the collided ball(linear)
00069     * @param x value of pixel that caused the collision
00070     * @param y value of pixel that caused the collision
00071     */
00072     void ball1_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(linear)
00073     
00074     /** Find the collided ball(parabolic)
00075     * @param x value of pixel that caused the collision
00076     * @param y value of pixel that caused the collision
00077     */
00078     void ball_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(parabolic)
00079     
00080     /**Check if cannon has been hit
00081     * @param N5110 class object
00082     * @param Objects class object
00083     * @return bool if collision has happened or not(bool)
00084     */
00085     bool cannon_smash(N5110 &lcd,Objects &objects);// checks if the cannon has crashed with anything
00086     
00087     /** Generate a random value
00088     * @param Gamepad class object
00089     * @return a random value in range of 0 to 100(int)
00090     */
00091     int random(Gamepad &pad);//generates a random number
00092     
00093     /**Govern the linear ball movement and creation
00094     * @param N5110 class object
00095     * @param Objects class object
00096     * @param Gamepad class object
00097     */
00098     void ball_creater_linear(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement equations
00099     
00100      /**Govern the parabolic ball movement and creation
00101     * @param N5110 class object
00102     * @param Objects class object
00103     * @param Gamepad class object
00104     */
00105     void ball_creater_parabolic(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement
00106     
00107     /**Round a value 
00108     * @param Number  value that needs rounding
00109     * @return a rounded value of passed value
00110     */
00111     int round(float number); //rounds a number
00112     
00113     /**Get score
00114     * @return the players current score
00115     */
00116     int get_score();//gets the players score
00117     
00118 private:
00119     //variables
00120     int _initial_radiuss;//holds the intial ball radiuss which is 2
00121     int _cannon_y_pos; // holds the cannons y position
00122     int _score;//holds the score
00123     int _counter;//checks if the parabolic ball has to go up or down
00124     int _previous; //the previous parabolic x value
00125     int _now;// the current parabolic x value
00126     vector <int> created_balls;//holds linear balls
00127     vector <int> created_ball;//holds the parabolic balls
00128     int _note_count; //holds the number of how many notes the note array has
00129     float _bpm; //beats per minute
00130 };
00131 #endif