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.
Missiles/Missiles.h@11:fd7f7b531e50, 2019-05-12 (annotated)
- Committer:
 - el17ttds
 - Date:
 - Sun May 12 16:31:45 2019 +0000
 - Revision:
 - 11:fd7f7b531e50
 - Parent:
 - 9:3a0194c87afe
 
Final submission. I have read and agreed with Statement of Academic Integrity.
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| el17ttds | 9:3a0194c87afe | 1 | /** My Missiles Class | 
| el17ttds | 9:3a0194c87afe | 2 | * @brief Stores and draws location data for three missiles belonging to our Hero. | 
| el17ttds | 9:3a0194c87afe | 3 | * @author Thomas Foster | 
| el17ttds | 9:3a0194c87afe | 4 | * @date May, 2019 | 
| el17ttds | 9:3a0194c87afe | 5 | */ | 
| el17ttds | 8:d1c04f0e4890 | 6 | #include "mbed.h" | 
| el17ttds | 8:d1c04f0e4890 | 7 | #include "N5110.h" | 
| el17ttds | 8:d1c04f0e4890 | 8 | #include "Gamepad.h" | 
| el17ttds | 8:d1c04f0e4890 | 9 | |
| el17ttds | 8:d1c04f0e4890 | 10 | class Missiles { | 
| el17ttds | 8:d1c04f0e4890 | 11 | |
| el17ttds | 8:d1c04f0e4890 | 12 | public: | 
| el17ttds | 9:3a0194c87afe | 13 | |
| el17ttds | 9:3a0194c87afe | 14 | /** Constructor */ | 
| el17ttds | 8:d1c04f0e4890 | 15 | Missiles(); | 
| el17ttds | 9:3a0194c87afe | 16 | |
| el17ttds | 9:3a0194c87afe | 17 | /** Initialises Missiles variables | 
| el17ttds | 9:3a0194c87afe | 18 | */ | 
| el17ttds | 8:d1c04f0e4890 | 19 | void init(); | 
| el17ttds | 9:3a0194c87afe | 20 | |
| el17ttds | 9:3a0194c87afe | 21 | /** Re writes Missiles parameters | 
| el17ttds | 9:3a0194c87afe | 22 | * @param user change in x (int) | 
| el17ttds | 9:3a0194c87afe | 23 | * @param user change in y (int) | 
| el17ttds | 9:3a0194c87afe | 24 | * @param Direction (Direction) | 
| el17ttds | 9:3a0194c87afe | 25 | * @param Button A pressed (bool) | 
| el17ttds | 9:3a0194c87afe | 26 | * @param Button B pressed (bool) | 
| el17ttds | 9:3a0194c87afe | 27 | * @param map x position (int) | 
| el17ttds | 9:3a0194c87afe | 28 | * @param map y position (int) | 
| el17ttds | 9:3a0194c87afe | 29 | * @param Missile 1 hit (bool) | 
| el17ttds | 9:3a0194c87afe | 30 | * @param Missile 2 hit (bool) | 
| el17ttds | 9:3a0194c87afe | 31 | * @param Missile 3 hit (bool) | 
| el17ttds | 9:3a0194c87afe | 32 | * @param Gamepad library (Gamepad) | 
| el17ttds | 9:3a0194c87afe | 33 | * @param reload rate (int) | 
| el17ttds | 9:3a0194c87afe | 34 | */ | 
| el17ttds | 9:3a0194c87afe | 35 | void write(int pix_x, int pix_y, Direction d, bool Apressed, bool Bpressed, int map_x, int map_y, bool m1_hit, bool m2_hit, bool m3_hit, Gamepad &pad, int rerate); | 
| el17ttds | 9:3a0194c87afe | 36 | |
| el17ttds | 9:3a0194c87afe | 37 | /** Draws Missiles on screen | 
| el17ttds | 9:3a0194c87afe | 38 | * @param The N5110 library (N5110) | 
| el17ttds | 9:3a0194c87afe | 39 | */ | 
| el17ttds | 8:d1c04f0e4890 | 40 | void draw(N5110 &lcd); | 
| el17ttds | 9:3a0194c87afe | 41 | |
| el17ttds | 9:3a0194c87afe | 42 | /** Gets Missile 1 position | 
| el17ttds | 9:3a0194c87afe | 43 | * @return Missile 1 position (Vector2D) | 
| el17ttds | 9:3a0194c87afe | 44 | */ | 
| el17ttds | 8:d1c04f0e4890 | 45 | Vector2D get_m1_pos(); | 
| el17ttds | 9:3a0194c87afe | 46 | |
| el17ttds | 9:3a0194c87afe | 47 | /** Gets Missile 2 position | 
| el17ttds | 9:3a0194c87afe | 48 | * @return Missile 2 position (Vector2D) | 
| el17ttds | 9:3a0194c87afe | 49 | */ | 
| el17ttds | 8:d1c04f0e4890 | 50 | Vector2D get_m2_pos(); | 
| el17ttds | 9:3a0194c87afe | 51 | |
| el17ttds | 9:3a0194c87afe | 52 | /** Gets Missile 3 position | 
| el17ttds | 9:3a0194c87afe | 53 | * @return Missile 3 position (Vector2D) | 
| el17ttds | 9:3a0194c87afe | 54 | */ | 
| el17ttds | 8:d1c04f0e4890 | 55 | Vector2D get_m3_pos(); | 
| el17ttds | 8:d1c04f0e4890 | 56 | |
| el17ttds | 9:3a0194c87afe | 57 | /** Calculates ammo | 
| el17ttds | 9:3a0194c87afe | 58 | * @param Gamepad library (Gamepad) | 
| el17ttds | 9:3a0194c87afe | 59 | */ | 
| el17ttds | 9:3a0194c87afe | 60 | void show_ammo(Gamepad &pad); | 
| el17ttds | 9:3a0194c87afe | 61 | |
| el17ttds | 8:d1c04f0e4890 | 62 | private: | 
| el17ttds | 8:d1c04f0e4890 | 63 | void check_hit(); | 
| el17ttds | 8:d1c04f0e4890 | 64 | void move_missile(); | 
| el17ttds | 8:d1c04f0e4890 | 65 | void set_forward(); | 
| el17ttds | 8:d1c04f0e4890 | 66 | void set_back(); | 
| el17ttds | 8:d1c04f0e4890 | 67 | void direction(); | 
| el17ttds | 8:d1c04f0e4890 | 68 | void check_collision_wall(); | 
| el17ttds | 9:3a0194c87afe | 69 | void reload(); | 
| el17ttds | 9:3a0194c87afe | 70 | |
| el17ttds | 8:d1c04f0e4890 | 71 | int reload_rate; | 
| el17ttds | 8:d1c04f0e4890 | 72 | int _xStart; | 
| el17ttds | 8:d1c04f0e4890 | 73 | int _yStart; | 
| el17ttds | 8:d1c04f0e4890 | 74 | int _speed; | 
| el17ttds | 8:d1c04f0e4890 | 75 | float _changex; | 
| el17ttds | 8:d1c04f0e4890 | 76 | float _changey; | 
| el17ttds | 9:3a0194c87afe | 77 | int frame_counter; | 
| el17ttds | 9:3a0194c87afe | 78 | |
| el17ttds | 9:3a0194c87afe | 79 | int frame_counter1; | 
| el17ttds | 9:3a0194c87afe | 80 | int frame_counter2; | 
| el17ttds | 9:3a0194c87afe | 81 | int frame_counter3; | 
| el17ttds | 9:3a0194c87afe | 82 | bool _ready1; | 
| el17ttds | 9:3a0194c87afe | 83 | bool _ready2; | 
| el17ttds | 9:3a0194c87afe | 84 | bool _ready3; | 
| el17ttds | 9:3a0194c87afe | 85 | |
| el17ttds | 9:3a0194c87afe | 86 | int ammo; | 
| el17ttds | 8:d1c04f0e4890 | 87 | |
| el17ttds | 8:d1c04f0e4890 | 88 | Direction _d; | 
| el17ttds | 8:d1c04f0e4890 | 89 | bool _Apressed; | 
| el17ttds | 8:d1c04f0e4890 | 90 | bool _Bpressed; | 
| el17ttds | 8:d1c04f0e4890 | 91 | |
| el17ttds | 8:d1c04f0e4890 | 92 | int _pix_x; | 
| el17ttds | 8:d1c04f0e4890 | 93 | int _pix_y; | 
| el17ttds | 8:d1c04f0e4890 | 94 | int _map_x; | 
| el17ttds | 8:d1c04f0e4890 | 95 | int _map_y; | 
| el17ttds | 8:d1c04f0e4890 | 96 | |
| el17ttds | 8:d1c04f0e4890 | 97 | bool _m1_hit; | 
| el17ttds | 8:d1c04f0e4890 | 98 | bool _m1; | 
| el17ttds | 8:d1c04f0e4890 | 99 | int _m1x; | 
| el17ttds | 8:d1c04f0e4890 | 100 | int _m1y; | 
| el17ttds | 8:d1c04f0e4890 | 101 | float _changex1; | 
| el17ttds | 8:d1c04f0e4890 | 102 | float _changey1; | 
| el17ttds | 8:d1c04f0e4890 | 103 | bool _m2_hit; | 
| el17ttds | 8:d1c04f0e4890 | 104 | bool _m2; | 
| el17ttds | 8:d1c04f0e4890 | 105 | int _m2x; | 
| el17ttds | 8:d1c04f0e4890 | 106 | int _m2y; | 
| el17ttds | 8:d1c04f0e4890 | 107 | float _changex2; | 
| el17ttds | 8:d1c04f0e4890 | 108 | float _changey2; | 
| el17ttds | 8:d1c04f0e4890 | 109 | bool _m3_hit; | 
| el17ttds | 8:d1c04f0e4890 | 110 | bool _m3; | 
| el17ttds | 8:d1c04f0e4890 | 111 | int _m3x; | 
| el17ttds | 8:d1c04f0e4890 | 112 | int _m3y; | 
| el17ttds | 8:d1c04f0e4890 | 113 | float _changex3; | 
| el17ttds | 8:d1c04f0e4890 | 114 | float _changey3; | 
| el17ttds | 8:d1c04f0e4890 | 115 | }; |