Arturs Kozlovskis / Mbed 2 deprecated ELEC2645_Project_el18ak

Dependencies:   mbed

Committer:
thestudent
Date:
Tue May 19 09:14:10 2020 +0000
Revision:
25:b0c1d7955678
Parent:
24:74a53dd49806
Changed API documentation;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thestudent 6:33bdb54c2c88 1 #ifndef FUNCTIONS_H
thestudent 6:33bdb54c2c88 2 #define FUNCTIONS_H
thestudent 6:33bdb54c2c88 3
thestudent 6:33bdb54c2c88 4 //includes
thestudent 6:33bdb54c2c88 5 #include "mbed.h"
thestudent 6:33bdb54c2c88 6 #include "N5110.h"
thestudent 6:33bdb54c2c88 7 #include "Gamepad.h"
thestudent 6:33bdb54c2c88 8 #include "Objects.h"
thestudent 6:33bdb54c2c88 9
thestudent 23:cd38e48635e7 10 //holds parabolic ball values
thestudent 23:cd38e48635e7 11 /** Struct for parabolic ball's varibales*/
thestudent 23:cd38e48635e7 12 struct Ball{
thestudent 23:cd38e48635e7 13 int ball_x_pos[10]; /**< Holds parabolic ball's x position(int)*/
thestudent 23:cd38e48635e7 14 float movement_y_counter[10]; /**< Sets the gravity with which the ball will fall(float)*/
thestudent 23:cd38e48635e7 15 int time[10];/**<Holds the time which is used in the balls movement(int)*/
thestudent 23:cd38e48635e7 16 int ball_y_pos[10];/**<Holds parabolic ball's y position(int)*/
thestudent 23:cd38e48635e7 17 int time_incrementer[10];/**<Increments time value(int)*/
thestudent 23:cd38e48635e7 18 int ball_x_incrementer[10];/**Increments ball's x position(int)*/
thestudent 23:cd38e48635e7 19 int delta_r[10]; /**< Holds ball's radiuss value(int)*/
thestudent 23:cd38e48635e7 20 int ball_trajectory_width[10];/**<Holds the value of ball's trajectories width(int)*/
thestudent 23:cd38e48635e7 21 };
thestudent 23:cd38e48635e7 22
thestudent 23:cd38e48635e7 23 //holds linear ball vvalues
thestudent 23:cd38e48635e7 24 /**Struct for linear ball's varables*/
thestudent 23:cd38e48635e7 25 struct Ball_linear{
thestudent 23:cd38e48635e7 26 int ball_x_pos[10]; /**< Holds ball's x position(int)*/
thestudent 23:cd38e48635e7 27 int movement_y_counter[10]; /**Sets the gravity with which the ball will fall(int)*/
thestudent 23:cd38e48635e7 28 int ball_y_pos[10];/**<Ball's y position(int)*/
thestudent 23:cd38e48635e7 29 int time_incrementer[10];/**<Increments the y(initaly time) value(int)*/
thestudent 23:cd38e48635e7 30 int ball_x_incrementer[10];/**<Increments ball's x value(int)*/
thestudent 23:cd38e48635e7 31 int delta_r[10];/**< Holds ball's radiuss value(int)*/
thestudent 23:cd38e48635e7 32 };
thestudent 23:cd38e48635e7 33
thestudent 25:b0c1d7955678 34 /**Functions class
thestudent 21:32429d8e90ff 35 * @brief Contains the game engine
thestudent 21:32429d8e90ff 36 * @author Arturs Kozlovskis
thestudent 21:32429d8e90ff 37 * @date April,2020
thestudent 21:32429d8e90ff 38 */
thestudent 9:4b11ee1155ad 39 class Functions
thestudent 6:33bdb54c2c88 40 {
thestudent 6:33bdb54c2c88 41 public:
thestudent 21:32429d8e90ff 42 /**Constructor*/
thestudent 6:33bdb54c2c88 43 Functions();
thestudent 21:32429d8e90ff 44
thestudent 21:32429d8e90ff 45 /** Draw parabolic ball
thestudent 21:32429d8e90ff 46 * @param N5110 class object
thestudent 25:b0c1d7955678 47 * @param Objects class object
thestudent 24:74a53dd49806 48 * @param Gamepad class object
thestudent 25:b0c1d7955678 49 * @param c tell the function which ball to chose from(int)
thestudent 21:32429d8e90ff 50 */
thestudent 24:74a53dd49806 51 void ball_position_parabolic( N5110 &lcd, Objects &objects,Gamepad &pad, int c);//governs the balls movement in a parabolic way
thestudent 21:32429d8e90ff 52
thestudent 21:32429d8e90ff 53 /** Draw linear ball
thestudent 21:32429d8e90ff 54 * @param N5110 class object
thestudent 25:b0c1d7955678 55 * @param Objects class object
thestudent 24:74a53dd49806 56 * @param Gamepad class object
thestudent 25:b0c1d7955678 57 * @param c tell the function which ball to chose from(int)
thestudent 21:32429d8e90ff 58 */
thestudent 24:74a53dd49806 59 void ball_position_linear (N5110 &lcd, Objects &objects,Gamepad &pad, int c);//governs the balls movement in a linear way
thestudent 21:32429d8e90ff 60
thestudent 21:32429d8e90ff 61 /** Check for collisions
thestudent 21:32429d8e90ff 62 * @param N5110 class object
thestudent 25:b0c1d7955678 63 * @param Objects class object
thestudent 24:74a53dd49806 64 * @param Gamepad class object
thestudent 21:32429d8e90ff 65 */
thestudent 24:74a53dd49806 66 void collision_checker(N5110 &lcd,Objects &objects,Gamepad &pad);//checks if the shot has coma into contact with the ball
thestudent 21:32429d8e90ff 67
thestudent 21:32429d8e90ff 68 /** Find the collided ball(linear)
thestudent 25:b0c1d7955678 69 * @param x value of pixel that caused the collision
thestudent 25:b0c1d7955678 70 * @param y value of pixel that caused the collision
thestudent 21:32429d8e90ff 71 */
thestudent 10:f5b920a6a71a 72 void ball1_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(linear)
thestudent 21:32429d8e90ff 73
thestudent 21:32429d8e90ff 74 /** Find the collided ball(parabolic)
thestudent 25:b0c1d7955678 75 * @param x value of pixel that caused the collision
thestudent 25:b0c1d7955678 76 * @param y value of pixel that caused the collision
thestudent 21:32429d8e90ff 77 */
thestudent 10:f5b920a6a71a 78 void ball_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(parabolic)
thestudent 21:32429d8e90ff 79
thestudent 21:32429d8e90ff 80 /**Check if cannon has been hit
thestudent 21:32429d8e90ff 81 * @param N5110 class object
thestudent 25:b0c1d7955678 82 * @param Objects class object
thestudent 25:b0c1d7955678 83 * @return bool if collision has happened or not(bool)
thestudent 21:32429d8e90ff 84 */
thestudent 11:4722bf70b2be 85 bool cannon_smash(N5110 &lcd,Objects &objects);// checks if the cannon has crashed with anything
thestudent 21:32429d8e90ff 86
thestudent 21:32429d8e90ff 87 /** Generate a random value
thestudent 21:32429d8e90ff 88 * @param Gamepad class object
thestudent 25:b0c1d7955678 89 * @return a random value in range of 0 to 100(int)
thestudent 21:32429d8e90ff 90 */
thestudent 11:4722bf70b2be 91 int random(Gamepad &pad);//generates a random number
thestudent 21:32429d8e90ff 92
thestudent 21:32429d8e90ff 93 /**Govern the linear ball movement and creation
thestudent 21:32429d8e90ff 94 * @param N5110 class object
thestudent 25:b0c1d7955678 95 * @param Objects class object
thestudent 21:32429d8e90ff 96 * @param Gamepad class object
thestudent 21:32429d8e90ff 97 */
thestudent 14:739115711bf8 98 void ball_creater_linear(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement equations
thestudent 21:32429d8e90ff 99
thestudent 21:32429d8e90ff 100 /**Govern the parabolic ball movement and creation
thestudent 21:32429d8e90ff 101 * @param N5110 class object
thestudent 25:b0c1d7955678 102 * @param Objects class object
thestudent 21:32429d8e90ff 103 * @param Gamepad class object
thestudent 21:32429d8e90ff 104 */
thestudent 14:739115711bf8 105 void ball_creater_parabolic(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement
thestudent 21:32429d8e90ff 106
thestudent 21:32429d8e90ff 107 /**Round a value
thestudent 25:b0c1d7955678 108 * @param Number value that needs rounding
thestudent 25:b0c1d7955678 109 * @return a rounded value of passed value
thestudent 21:32429d8e90ff 110 */
thestudent 15:3f558f8b54ea 111 int round(float number); //rounds a number
thestudent 21:32429d8e90ff 112
thestudent 21:32429d8e90ff 113 /**Get score
thestudent 25:b0c1d7955678 114 * @return the players current score
thestudent 21:32429d8e90ff 115 */
thestudent 13:1dbef50789ed 116 int get_score();//gets the players score
thestudent 13:1dbef50789ed 117
thestudent 6:33bdb54c2c88 118 private:
thestudent 21:32429d8e90ff 119 //variables
thestudent 6:33bdb54c2c88 120 int _initial_radiuss;//holds the intial ball radiuss which is 2
thestudent 10:f5b920a6a71a 121 int _cannon_y_pos; // holds the cannons y position
thestudent 13:1dbef50789ed 122 int _score;//holds the score
thestudent 21:32429d8e90ff 123 int _counter;//checks if the parabolic ball has to go up or down
thestudent 21:32429d8e90ff 124 int _previous; //the previous parabolic x value
thestudent 21:32429d8e90ff 125 int _now;// the current parabolic x value
thestudent 21:32429d8e90ff 126 vector <int> created_balls;//holds linear balls
thestudent 21:32429d8e90ff 127 vector <int> created_ball;//holds the parabolic balls
thestudent 22:f1811602a817 128 int _note_count; //holds the number of how many notes the note array has
thestudent 24:74a53dd49806 129 float _bpm; //beats per minute
thestudent 6:33bdb54c2c88 130 };
thestudent 6:33bdb54c2c88 131 #endif