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.
Dependencies: mbed Gamepad N5110 mbed-rtos
MiniEnemy/MiniEnemy.h@7:574c66ebd8b0, 2019-05-09 (annotated)
- Committer:
- RexRoshan
- Date:
- Thu May 09 09:54:50 2019 +0000
- Revision:
- 7:574c66ebd8b0
- Child:
- 9:c5a19e358c07
Documentation has been completed and the code has been slightly modified
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RexRoshan | 7:574c66ebd8b0 | 1 | #ifndef MINIENEMY_H |
| RexRoshan | 7:574c66ebd8b0 | 2 | #define MINIENEMY_H |
| RexRoshan | 7:574c66ebd8b0 | 3 | |
| RexRoshan | 7:574c66ebd8b0 | 4 | #include "mbed.h" |
| RexRoshan | 7:574c66ebd8b0 | 5 | #include "N5110.h" |
| RexRoshan | 7:574c66ebd8b0 | 6 | #include "Gamepad.h" |
| RexRoshan | 7:574c66ebd8b0 | 7 | |
| RexRoshan | 7:574c66ebd8b0 | 8 | /** MiniEnemy Class |
| RexRoshan | 7:574c66ebd8b0 | 9 | * @brief Enemy for the minigame |
| RexRoshan | 7:574c66ebd8b0 | 10 | * @author Rex Roshan Raj |
| RexRoshan | 7:574c66ebd8b0 | 11 | */ |
| RexRoshan | 7:574c66ebd8b0 | 12 | class MiniEnemy |
| RexRoshan | 7:574c66ebd8b0 | 13 | { |
| RexRoshan | 7:574c66ebd8b0 | 14 | |
| RexRoshan | 7:574c66ebd8b0 | 15 | public: |
| RexRoshan | 7:574c66ebd8b0 | 16 | /** Constructor */ |
| RexRoshan | 7:574c66ebd8b0 | 17 | MiniEnemy(); |
| RexRoshan | 7:574c66ebd8b0 | 18 | |
| RexRoshan | 7:574c66ebd8b0 | 19 | /** Destructor */ |
| RexRoshan | 7:574c66ebd8b0 | 20 | ~MiniEnemy(); |
| RexRoshan | 7:574c66ebd8b0 | 21 | |
| RexRoshan | 7:574c66ebd8b0 | 22 | /** Initialises the parameters */ |
| RexRoshan | 7:574c66ebd8b0 | 23 | void init(); |
| RexRoshan | 7:574c66ebd8b0 | 24 | |
| RexRoshan | 7:574c66ebd8b0 | 25 | /** Generates the location |
| RexRoshan | 7:574c66ebd8b0 | 26 | * @brief Generates and sets the location of the enemy once it has been hit |
| RexRoshan | 7:574c66ebd8b0 | 27 | */ |
| RexRoshan | 7:574c66ebd8b0 | 28 | Vector2D location(); |
| RexRoshan | 7:574c66ebd8b0 | 29 | |
| RexRoshan | 7:574c66ebd8b0 | 30 | /** Draws the enemy |
| RexRoshan | 7:574c66ebd8b0 | 31 | * @param N5110 lcd |
| RexRoshan | 7:574c66ebd8b0 | 32 | * @brief Draws the enemy in stage one |
| RexRoshan | 7:574c66ebd8b0 | 33 | */ |
| RexRoshan | 7:574c66ebd8b0 | 34 | void enemy(N5110 &lcd); |
| RexRoshan | 7:574c66ebd8b0 | 35 | |
| RexRoshan | 7:574c66ebd8b0 | 36 | /** Updates the movement |
| RexRoshan | 7:574c66ebd8b0 | 37 | * @brief Changes the y position for animation once the enemy has died |
| RexRoshan | 7:574c66ebd8b0 | 38 | */ |
| RexRoshan | 7:574c66ebd8b0 | 39 | void update(); |
| RexRoshan | 7:574c66ebd8b0 | 40 | |
| RexRoshan | 7:574c66ebd8b0 | 41 | /** Adds the value of score by 1 */ |
| RexRoshan | 7:574c66ebd8b0 | 42 | void add_score(); |
| RexRoshan | 7:574c66ebd8b0 | 43 | |
| RexRoshan | 7:574c66ebd8b0 | 44 | /** Gets the value of the score |
| RexRoshan | 7:574c66ebd8b0 | 45 | * @returns value in range 0 to 10 |
| RexRoshan | 7:574c66ebd8b0 | 46 | */ |
| RexRoshan | 7:574c66ebd8b0 | 47 | int get_score(); |
| RexRoshan | 7:574c66ebd8b0 | 48 | |
| RexRoshan | 7:574c66ebd8b0 | 49 | /** Adds the value of health by 1 */ |
| RexRoshan | 7:574c66ebd8b0 | 50 | void add_health(); |
| RexRoshan | 7:574c66ebd8b0 | 51 | |
| RexRoshan | 7:574c66ebd8b0 | 52 | /** Gets the value of the health |
| RexRoshan | 7:574c66ebd8b0 | 53 | * @returns value in range 0 to 5 |
| RexRoshan | 7:574c66ebd8b0 | 54 | */ |
| RexRoshan | 7:574c66ebd8b0 | 55 | int get_health(); |
| RexRoshan | 7:574c66ebd8b0 | 56 | |
| RexRoshan | 7:574c66ebd8b0 | 57 | /** Sets the value of the health |
| RexRoshan | 7:574c66ebd8b0 | 58 | * @returns value of 0 |
| RexRoshan | 7:574c66ebd8b0 | 59 | */ |
| RexRoshan | 7:574c66ebd8b0 | 60 | int set_health(); |
| RexRoshan | 7:574c66ebd8b0 | 61 | |
| RexRoshan | 7:574c66ebd8b0 | 62 | /** Adds 1 to movement speed*/ |
| RexRoshan | 7:574c66ebd8b0 | 63 | void add_fast(); |
| RexRoshan | 7:574c66ebd8b0 | 64 | |
| RexRoshan | 7:574c66ebd8b0 | 65 | /** Gets the value of the fast |
| RexRoshan | 7:574c66ebd8b0 | 66 | * @returns value in range 1 to 7 |
| RexRoshan | 7:574c66ebd8b0 | 67 | */ |
| RexRoshan | 7:574c66ebd8b0 | 68 | int get_fast(); |
| RexRoshan | 7:574c66ebd8b0 | 69 | |
| RexRoshan | 7:574c66ebd8b0 | 70 | /** Sets the value of the fast |
| RexRoshan | 7:574c66ebd8b0 | 71 | * @returns value in range 0 |
| RexRoshan | 7:574c66ebd8b0 | 72 | */ |
| RexRoshan | 7:574c66ebd8b0 | 73 | int set_fast(); |
| RexRoshan | 7:574c66ebd8b0 | 74 | |
| RexRoshan | 7:574c66ebd8b0 | 75 | /** Gets the position of the enemy |
| RexRoshan | 7:574c66ebd8b0 | 76 | * @returns a struct with x,y members which corresponds to x and y position respectively |
| RexRoshan | 7:574c66ebd8b0 | 77 | */ |
| RexRoshan | 7:574c66ebd8b0 | 78 | Vector2D get_enemy_pos(); |
| RexRoshan | 7:574c66ebd8b0 | 79 | |
| RexRoshan | 7:574c66ebd8b0 | 80 | /** Sets the position of the enemy |
| RexRoshan | 7:574c66ebd8b0 | 81 | * @param position of the enemy |
| RexRoshan | 7:574c66ebd8b0 | 82 | */ |
| RexRoshan | 7:574c66ebd8b0 | 83 | void set_enemy_pos(Vector2D e); |
| RexRoshan | 7:574c66ebd8b0 | 84 | |
| RexRoshan | 7:574c66ebd8b0 | 85 | |
| RexRoshan | 7:574c66ebd8b0 | 86 | private: |
| RexRoshan | 7:574c66ebd8b0 | 87 | |
| RexRoshan | 7:574c66ebd8b0 | 88 | // methods |
| RexRoshan | 7:574c66ebd8b0 | 89 | Vector2D _location; |
| RexRoshan | 7:574c66ebd8b0 | 90 | int a; |
| RexRoshan | 7:574c66ebd8b0 | 91 | int b; |
| RexRoshan | 7:574c66ebd8b0 | 92 | int x; |
| RexRoshan | 7:574c66ebd8b0 | 93 | int y; |
| RexRoshan | 7:574c66ebd8b0 | 94 | int _fast; |
| RexRoshan | 7:574c66ebd8b0 | 95 | int _score; |
| RexRoshan | 7:574c66ebd8b0 | 96 | int _health; |
| RexRoshan | 7:574c66ebd8b0 | 97 | |
| RexRoshan | 7:574c66ebd8b0 | 98 | }; |
| RexRoshan | 7:574c66ebd8b0 | 99 | |
| RexRoshan | 7:574c66ebd8b0 | 100 | #endif |