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/Objects.h@21:32429d8e90ff, 2020-05-12 (annotated)
- Committer:
- thestudent
- Date:
- Tue May 12 15:12:59 2020 +0000
- Revision:
- 21:32429d8e90ff
- Parent:
- 16:e2aaef863d7c
- Child:
- 25:b0c1d7955678
Final version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| thestudent | 6:33bdb54c2c88 | 1 | #ifndef OBJECTS_H |
| thestudent | 6:33bdb54c2c88 | 2 | #define OBJECTS_H |
| thestudent | 6:33bdb54c2c88 | 3 | |
| thestudent | 6:33bdb54c2c88 | 4 | #include "mbed.h" |
| thestudent | 6:33bdb54c2c88 | 5 | #include "N5110.h" |
| thestudent | 6:33bdb54c2c88 | 6 | #include "Gamepad.h" |
| thestudent | 6:33bdb54c2c88 | 7 | #include <vector> |
| thestudent | 21:32429d8e90ff | 8 | /** Object class |
| thestudent | 21:32429d8e90ff | 9 | * @brief draws game objects on the lcd screen |
| thestudent | 21:32429d8e90ff | 10 | * @author Arturs Kozlovskis |
| thestudent | 21:32429d8e90ff | 11 | * @date April,2020 |
| thestudent | 21:32429d8e90ff | 12 | */ |
| thestudent | 6:33bdb54c2c88 | 13 | |
| thestudent | 10:f5b920a6a71a | 14 | class Objects |
| thestudent | 10:f5b920a6a71a | 15 | { |
| thestudent | 10:f5b920a6a71a | 16 | public: |
| thestudent | 10:f5b920a6a71a | 17 | |
| thestudent | 21:32429d8e90ff | 18 | /**Constructor */ |
| thestudent | 10:f5b920a6a71a | 19 | Objects();//initialises variables |
| thestudent | 21:32429d8e90ff | 20 | |
| thestudent | 21:32429d8e90ff | 21 | /** Draw the base of the game |
| thestudent | 21:32429d8e90ff | 22 | * @param N5110 class object |
| thestudent | 21:32429d8e90ff | 23 | */ |
| thestudent | 10:f5b920a6a71a | 24 | void draw_base(N5110 &lcd);// draws the base |
| thestudent | 21:32429d8e90ff | 25 | |
| thestudent | 21:32429d8e90ff | 26 | /** Update the cannon position |
| thestudent | 21:32429d8e90ff | 27 | * @param Gamepad class object |
| thestudent | 21:32429d8e90ff | 28 | */ |
| thestudent | 10:f5b920a6a71a | 29 | void cannon_position(Gamepad &pad);// changes the cannon position depending of the joystick |
| thestudent | 21:32429d8e90ff | 30 | |
| thestudent | 21:32429d8e90ff | 31 | /** Draw a cannon |
| thestudent | 21:32429d8e90ff | 32 | * @param N5110 class object |
| thestudent | 21:32429d8e90ff | 33 | */ |
| thestudent | 10:f5b920a6a71a | 34 | void draw_cannon(N5110 &lcd);//draws the cannon |
| thestudent | 21:32429d8e90ff | 35 | |
| thestudent | 21:32429d8e90ff | 36 | /** Draw shots |
| thestudent | 21:32429d8e90ff | 37 | * @param N5110 class object |
| thestudent | 21:32429d8e90ff | 38 | * @param Gamepad class object |
| thestudent | 21:32429d8e90ff | 39 | * @param update value(bool) |
| thestudent | 21:32429d8e90ff | 40 | */ |
| thestudent | 16:e2aaef863d7c | 41 | void draw_shots(N5110 &lcd,Gamepad &pad,bool c);// makes the shoting on the screen |
| thestudent | 21:32429d8e90ff | 42 | |
| thestudent | 21:32429d8e90ff | 43 | /** Draw ball |
| thestudent | 21:32429d8e90ff | 44 | * @param N5110 calss object |
| thestudent | 21:32429d8e90ff | 45 | * @param ball x position(int) |
| thestudent | 21:32429d8e90ff | 46 | * @param ball y position(int) |
| thestudent | 21:32429d8e90ff | 47 | * @param the delta radiuss(int) |
| thestudent | 21:32429d8e90ff | 48 | */ |
| thestudent | 21:32429d8e90ff | 49 | void draw_ball(N5110 &lcd, int ball_x, int ball_y, int delta_r); //ball_x: balls x position; ball_y: balls y position; delta_r: added to the inital radiuss to make the ball bigger |
| thestudent | 21:32429d8e90ff | 50 | |
| thestudent | 21:32429d8e90ff | 51 | /** Get size value of _shot_y_pos vector |
| thestudent | 21:32429d8e90ff | 52 | * @return size of vector |
| thestudent | 21:32429d8e90ff | 53 | */ |
| thestudent | 10:f5b920a6a71a | 54 | int get_size();//gets the size of _shot_y_pos vector |
| thestudent | 21:32429d8e90ff | 55 | /** Get x value |
| thestudent | 21:32429d8e90ff | 56 | * @param which shot value to return(int) |
| thestudent | 21:32429d8e90ff | 57 | * @return shot x value |
| thestudent | 21:32429d8e90ff | 58 | */ |
| thestudent | 10:f5b920a6a71a | 59 | int get_x_value(int i);//gets _shot_x_pos(i) |
| thestudent | 21:32429d8e90ff | 60 | |
| thestudent | 21:32429d8e90ff | 61 | /** Get y value |
| thestudent | 21:32429d8e90ff | 62 | * @param which shot value to return(int) |
| thestudent | 21:32429d8e90ff | 63 | * @return shot y value |
| thestudent | 21:32429d8e90ff | 64 | */ |
| thestudent | 10:f5b920a6a71a | 65 | int get_y_value(int i);//gets _shot_y_pos(i) |
| thestudent | 21:32429d8e90ff | 66 | |
| thestudent | 21:32429d8e90ff | 67 | /** Erase a shot |
| thestudent | 21:32429d8e90ff | 68 | * @param which shot value to erase(int) |
| thestudent | 21:32429d8e90ff | 69 | */ |
| thestudent | 9:4b11ee1155ad | 70 | void erase_shot(int i);//erases _shot_x_pos(i) and _shot_y_pos(i) |
| thestudent | 21:32429d8e90ff | 71 | |
| thestudent | 21:32429d8e90ff | 72 | /** Get cannon x position |
| thestudent | 21:32429d8e90ff | 73 | * @return cannon x position |
| thestudent | 21:32429d8e90ff | 74 | */ |
| thestudent | 10:f5b920a6a71a | 75 | int get_x_cannon(); |
| thestudent | 10:f5b920a6a71a | 76 | |
| thestudent | 10:f5b920a6a71a | 77 | private: |
| thestudent | 21:32429d8e90ff | 78 | //variables |
| thestudent | 10:f5b920a6a71a | 79 | int _cannon_pos; //stores the positon of the cannon |
| thestudent | 10:f5b920a6a71a | 80 | int _initial_shot_pos;//stroes the initial vertical position of the shot |
| thestudent | 10:f5b920a6a71a | 81 | int _shot_incrementer;//increments the shot on the lcd by 2 |
| thestudent | 10:f5b920a6a71a | 82 | int _radiuss;// the initiak radiuss of the ball |
| thestudent | 21:32429d8e90ff | 83 | vector <int> _shot_y_pos; //holds the shots y positions |
| thestudent | 21:32429d8e90ff | 84 | vector <int> _shot_x_pos;//holds the shots x positons |
| thestudent | 10:f5b920a6a71a | 85 | |
| thestudent | 10:f5b920a6a71a | 86 | }; |
| thestudent | 10:f5b920a6a71a | 87 | #endif |