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 MotionSensor
Bullets/Bullets.h@60:44ddfb791e2b, 2019-05-09 (annotated)
- Committer:
- el17sm
- Date:
- Thu May 09 14:55:43 2019 +0000
- Revision:
- 60:44ddfb791e2b
- Parent:
- Entity/Player/Bullets/Bullets.h@59:fd4669864b67
Separated
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17sm | 32:fe6359ef9916 | 1 | #ifndef BULLETS_H |
| el17sm | 32:fe6359ef9916 | 2 | #define BULLETS_H |
| el17sm | 32:fe6359ef9916 | 3 | #include "Entity.h" |
| el17sm | 32:fe6359ef9916 | 4 | |
| el17sm | 58:c8d90bb7404a | 5 | /**Bullets Class |
| el17sm | 59:fd4669864b67 | 6 | *@author Steven Mahasin |
| el17sm | 59:fd4669864b67 | 7 | *@brief Creates a Bullet which inherits the Entity class, this will be a created projectile by the player class |
| el17sm | 59:fd4669864b67 | 8 | *@date May 2019 |
| el17sm | 58:c8d90bb7404a | 9 | */ |
| el17sm | 32:fe6359ef9916 | 10 | class Bullets : public Entity |
| el17sm | 32:fe6359ef9916 | 11 | { |
| el17sm | 32:fe6359ef9916 | 12 | |
| el17sm | 32:fe6359ef9916 | 13 | public: |
| el17sm | 58:c8d90bb7404a | 14 | /** Constructor |
| el17sm | 58:c8d90bb7404a | 15 | * @brief creates a bullet at positions pos_x and pos_y travelling at face dir |
| el17sm | 59:fd4669864b67 | 16 | * @param pos_x - initialise _position.x |
| el17sm | 59:fd4669864b67 | 17 | * @param pos_y - initialise _position.y |
| el17sm | 59:fd4669864b67 | 18 | * @param dir - initialise _face |
| el17sm | 58:c8d90bb7404a | 19 | */ |
| el17sm | 58:c8d90bb7404a | 20 | Bullets(float pos_x, float pos_y, int dir); |
| el17sm | 32:fe6359ef9916 | 21 | |
| el17sm | 32:fe6359ef9916 | 22 | // Functions |
| el17sm | 58:c8d90bb7404a | 23 | /** |
| el17sm | 58:c8d90bb7404a | 24 | * @brief function moves the bullet on it's face at a speed |
| el17sm | 59:fd4669864b67 | 25 | * @param speed - the speed of the bullet |
| el17sm | 59:fd4669864b67 | 26 | * @param unused - not used |
| el17sm | 59:fd4669864b67 | 27 | * @param map - not used |
| el17sm | 59:fd4669864b67 | 28 | * @param doorways - not used |
| el17sm | 58:c8d90bb7404a | 29 | */ |
| el17sm | 58:c8d90bb7404a | 30 | virtual void move(float speed, float unused, char * map, bool * doorways); |
| el17sm | 58:c8d90bb7404a | 31 | /** |
| el17sm | 58:c8d90bb7404a | 32 | * @brief draws the bullet onto the screen |
| el17sm | 59:fd4669864b67 | 33 | * @param lcd - the screen where the bullet is drawn |
| el17sm | 58:c8d90bb7404a | 34 | */ |
| el17sm | 32:fe6359ef9916 | 35 | virtual void draw(N5110 &lcd); |
| el17sm | 58:c8d90bb7404a | 36 | /** |
| el17sm | 58:c8d90bb7404a | 37 | * @brief reduce _hp by damage |
| el17sm | 59:fd4669864b67 | 38 | * @param damage - the amount of damage to be taken |
| el17sm | 58:c8d90bb7404a | 39 | */ |
| el17sm | 32:fe6359ef9916 | 40 | virtual void take_damage(int damage); |
| el17sm | 58:c8d90bb7404a | 41 | /** |
| el17sm | 58:c8d90bb7404a | 42 | * @brief checks if the bullet is out of bounds (hit wall or out of screen) |
| el17sm | 59:fd4669864b67 | 43 | * @param map - the 2d map array that dictates where there are walls or empty space |
| el17sm | 59:fd4669864b67 | 44 | * @param doorways - an array that dictates which side of the wall has a doorway |
| el17sm | 58:c8d90bb7404a | 45 | * @returns true if bullet is out of bounds |
| el17sm | 58:c8d90bb7404a | 46 | */ |
| el17sm | 34:1d5b4da3935e | 47 | bool out_of_bounds_check(char * map, bool * doorways); |
| el17sm | 32:fe6359ef9916 | 48 | }; |
| el17sm | 32:fe6359ef9916 | 49 | |
| el17sm | 33:4f3948dcd2f7 | 50 | const char bullets_sprite[3][3] = {{1,1,1}, |
| el17sm | 32:fe6359ef9916 | 51 | {1,1,1}, |
| el17sm | 32:fe6359ef9916 | 52 | {1,1,1} |
| el17sm | 32:fe6359ef9916 | 53 | }; |
| el17sm | 32:fe6359ef9916 | 54 | |
| el17sm | 32:fe6359ef9916 | 55 | #endif |