Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
My_game_clases/Functions.h@15:3f558f8b54ea, 2020-05-01 (annotated)
- Committer:
- thestudent
- Date:
- Fri May 01 12:54:25 2020 +0000
- Revision:
- 15:3f558f8b54ea
- Parent:
- 14:739115711bf8
- Child:
- 21:32429d8e90ff
Finished with parabolic ball movement;
Who changed what in which revision?
| User | Revision | Line number | New 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 | 7:82079de8bcd6 | 10 | struct Ball{ |
| thestudent | 14:739115711bf8 | 11 | int ball_x_pos[10]; // balls x position |
| thestudent | 8:09eb8fe2bb20 | 12 | float movement_y_counter[10]; //sets the gravity with which the ball will fall |
| thestudent | 7:82079de8bcd6 | 13 | int time[10];//the time as in the y postion of the ball which will governed by equation y = _y_initial + _movement_y_counter * _time^2 |
| thestudent | 7:82079de8bcd6 | 14 | int ball_y_pos[10];//balls_y_position |
| thestudent | 7:82079de8bcd6 | 15 | int time_incrementer[10];//increments time value |
| thestudent | 7:82079de8bcd6 | 16 | int ball_x_incrementer[10];//increments movement_x_pos value |
| thestudent | 7:82079de8bcd6 | 17 | int delta_r[10]; // defines the ball size |
| thestudent | 15:3f558f8b54ea | 18 | int ball_trajectory_width[10]; |
| thestudent | 15:3f558f8b54ea | 19 | |
| thestudent | 15:3f558f8b54ea | 20 | |
| thestudent | 8:09eb8fe2bb20 | 21 | |
| thestudent | 7:82079de8bcd6 | 22 | }; |
| thestudent | 7:82079de8bcd6 | 23 | struct Ball_linear{ |
| thestudent | 9:4b11ee1155ad | 24 | int ball_x_pos[10]; // moves the ball across the screen |
| thestudent | 7:82079de8bcd6 | 25 | int movement_y_counter[10]; //sets the gravity with which the ball will fall |
| thestudent | 7:82079de8bcd6 | 26 | int ball_y_pos[10];//balls_y_position |
| thestudent | 7:82079de8bcd6 | 27 | int time_incrementer[10];//increments time value |
| thestudent | 7:82079de8bcd6 | 28 | int ball_x_incrementer[10];//increments movement_x_pos value |
| thestudent | 7:82079de8bcd6 | 29 | int delta_r[10]; // defines the ball size |
| thestudent | 14:739115711bf8 | 30 | |
| thestudent | 14:739115711bf8 | 31 | |
| thestudent | 7:82079de8bcd6 | 32 | }; |
| thestudent | 7:82079de8bcd6 | 33 | |
| thestudent | 9:4b11ee1155ad | 34 | class Functions |
| thestudent | 6:33bdb54c2c88 | 35 | { |
| thestudent | 6:33bdb54c2c88 | 36 | public: |
| thestudent | 6:33bdb54c2c88 | 37 | Functions(); |
| thestudent | 12:f7dfd44569b6 | 38 | void ball_position_parabolic( N5110 &lcd, Objects &objects, int c);//governs the balls movement in a parabolic way |
| thestudent | 12:f7dfd44569b6 | 39 | void ball_position_linear (N5110 &lcd, Objects &objects, int c);//governs the balls movement in a linear way |
| thestudent | 9:4b11ee1155ad | 40 | void collision_checker(N5110 &lcd,Objects &objects);//checks if the shot has coma into contact with the ball |
| thestudent | 10:f5b920a6a71a | 41 | void ball1_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(linear) |
| thestudent | 10:f5b920a6a71a | 42 | void ball_finder(int x, int y);//checks which ball has been hit by a shot and then decreses it size(parabolic) |
| thestudent | 11:4722bf70b2be | 43 | bool cannon_smash(N5110 &lcd,Objects &objects);// checks if the cannon has crashed with anything |
| thestudent | 11:4722bf70b2be | 44 | int random(Gamepad &pad);//generates a random number |
| thestudent | 14:739115711bf8 | 45 | void ball_creater_linear(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement equations |
| thestudent | 14:739115711bf8 | 46 | void ball_creater_parabolic(N5110 &lcd, Objects &objects, Gamepad &pad);//controls ball making and their movement |
| thestudent | 15:3f558f8b54ea | 47 | int round(float number); //rounds a number |
| thestudent | 13:1dbef50789ed | 48 | int get_score();//gets the players score |
| thestudent | 13:1dbef50789ed | 49 | |
| thestudent | 14:739115711bf8 | 50 | vector <int> created_balls;//holds linear balls |
| thestudent | 14:739115711bf8 | 51 | vector <int> created_ball;//holds the parabolic balls |
| thestudent | 15:3f558f8b54ea | 52 | |
| thestudent | 6:33bdb54c2c88 | 53 | |
| thestudent | 6:33bdb54c2c88 | 54 | private: |
| thestudent | 6:33bdb54c2c88 | 55 | int _initial_radiuss;//holds the intial ball radiuss which is 2 |
| thestudent | 10:f5b920a6a71a | 56 | int _cannon_y_pos; // holds the cannons y position |
| thestudent | 13:1dbef50789ed | 57 | int _score;//holds the score |
| thestudent | 15:3f558f8b54ea | 58 | int _counter; |
| thestudent | 15:3f558f8b54ea | 59 | int _previous; |
| thestudent | 15:3f558f8b54ea | 60 | int _now; |
| thestudent | 6:33bdb54c2c88 | 61 | }; |
| thestudent | 6:33bdb54c2c88 | 62 | #endif |