Hao zhang
/
el17h3z
HaoZhang SID: 201199702
Bullet/Bullet.h@2:867fdea920c1, 2020-05-14 (annotated)
- Committer:
- zh870524589
- Date:
- Thu May 14 17:45:05 2020 +0000
- Revision:
- 2:867fdea920c1
- Parent:
- 0:45ce241d316b
final
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zh870524589 | 0:45ce241d316b | 1 | #ifndef Bullet_H |
zh870524589 | 0:45ce241d316b | 2 | #define Bullet_H |
zh870524589 | 0:45ce241d316b | 3 | |
zh870524589 | 0:45ce241d316b | 4 | #include "mbed.h" |
zh870524589 | 0:45ce241d316b | 5 | #include "N5110.h" |
zh870524589 | 0:45ce241d316b | 6 | #include "Gamepad.h" |
zh870524589 | 0:45ce241d316b | 7 | #include "ETank.h" |
zh870524589 | 0:45ce241d316b | 8 | #include "MyTank.h" |
zh870524589 | 0:45ce241d316b | 9 | #include "iostream" |
zh870524589 | 0:45ce241d316b | 10 | #include "vector" |
zh870524589 | 0:45ce241d316b | 11 | #include "list" |
zh870524589 | 0:45ce241d316b | 12 | |
zh870524589 | 0:45ce241d316b | 13 | /** Bullet Class |
zh870524589 | 0:45ce241d316b | 14 | * @brief Create the bullets of tanks and set the bullets behavior and properties |
zh870524589 | 0:45ce241d316b | 15 | * @author HaoZhang |
zh870524589 | 0:45ce241d316b | 16 | * @date May, 2020 |
zh870524589 | 0:45ce241d316b | 17 | */ |
zh870524589 | 0:45ce241d316b | 18 | class MyTank; |
zh870524589 | 0:45ce241d316b | 19 | class ETank; |
zh870524589 | 0:45ce241d316b | 20 | |
zh870524589 | 0:45ce241d316b | 21 | class Bullet |
zh870524589 | 0:45ce241d316b | 22 | { |
zh870524589 | 0:45ce241d316b | 23 | public: |
zh870524589 | 0:45ce241d316b | 24 | /** Constructor */ |
zh870524589 | 0:45ce241d316b | 25 | Bullet(); |
zh870524589 | 0:45ce241d316b | 26 | /** Constructor |
zh870524589 | 0:45ce241d316b | 27 | *@param pad - get the direction of tank |
zh870524589 | 0:45ce241d316b | 28 | *@param p - get the position of tank |
zh870524589 | 0:45ce241d316b | 29 | */ |
zh870524589 | 0:45ce241d316b | 30 | Bullet(Gamepad &pad,Vector2D p); |
zh870524589 | 0:45ce241d316b | 31 | /** update the bullet of player's tank |
zh870524589 | 0:45ce241d316b | 32 | *@param lcd - Target Screen |
zh870524589 | 0:45ce241d316b | 33 | *@param prem_d - Keep the bullets in the same direction |
zh870524589 | 0:45ce241d316b | 34 | */ |
zh870524589 | 0:45ce241d316b | 35 | void update(N5110 &lcd,Direction prem_d); |
zh870524589 | 2:867fdea920c1 | 36 | /**update the bullet of enemy's tank |
zh870524589 | 0:45ce241d316b | 37 | *@param lcd - Target Screen |
zh870524589 | 0:45ce241d316b | 38 | *@param e_d - Keep the bullets in the same direction |
zh870524589 | 0:45ce241d316b | 39 | */ |
zh870524589 | 0:45ce241d316b | 40 | void et_update(N5110 &lcd,Direction e_d); |
zh870524589 | 0:45ce241d316b | 41 | /** It is used with bullet_collison to eliminate bullets |
zh870524589 | 0:45ce241d316b | 42 | *@param x - the value of bullet' x position |
zh870524589 | 0:45ce241d316b | 43 | *@param y - the value of bullet' y position |
zh870524589 | 0:45ce241d316b | 44 | */ |
zh870524589 | 0:45ce241d316b | 45 | void set_pos(int x,int y); |
zh870524589 | 0:45ce241d316b | 46 | /**check if the bullet go out of the screen */ |
zh870524589 | 0:45ce241d316b | 47 | bool destroy(); |
zh870524589 | 0:45ce241d316b | 48 | /**Check for collisions between bullets |
zh870524589 | 0:45ce241d316b | 49 | *@param t_pos - the position of bullets |
zh870524589 | 0:45ce241d316b | 50 | *@return the result of check |
zh870524589 | 0:45ce241d316b | 51 | */ |
zh870524589 | 0:45ce241d316b | 52 | bool destroyT(Vector2D t_pos); |
zh870524589 | 0:45ce241d316b | 53 | /**Eliminate collision bullets |
zh870524589 | 0:45ce241d316b | 54 | *@param lstBullets - the bullets of enemy |
zh870524589 | 0:45ce241d316b | 55 | *@param mtbullet - the bullets of player |
zh870524589 | 0:45ce241d316b | 56 | */ |
zh870524589 | 0:45ce241d316b | 57 | void bullet_collison(list<Bullet*> &lstBullets,list<Bullet*>&mtbullet); |
zh870524589 | 0:45ce241d316b | 58 | /**get the position of bullets*/ |
zh870524589 | 0:45ce241d316b | 59 | Vector2D get_pos(); |
zh870524589 | 0:45ce241d316b | 60 | |
zh870524589 | 0:45ce241d316b | 61 | |
zh870524589 | 0:45ce241d316b | 62 | private: |
zh870524589 | 0:45ce241d316b | 63 | |
zh870524589 | 0:45ce241d316b | 64 | int _x; |
zh870524589 | 0:45ce241d316b | 65 | int _y; |
zh870524589 | 0:45ce241d316b | 66 | Direction m_d; |
zh870524589 | 0:45ce241d316b | 67 | /** Used to store the direction of player's tank bullets*/ |
zh870524589 | 0:45ce241d316b | 68 | vector<Direction> v1; |
zh870524589 | 0:45ce241d316b | 69 | /** Used to store the direction of enemy's tank bullets*/ |
zh870524589 | 0:45ce241d316b | 70 | vector<Direction> v2; |
zh870524589 | 0:45ce241d316b | 71 | |
zh870524589 | 0:45ce241d316b | 72 | |
zh870524589 | 0:45ce241d316b | 73 | |
zh870524589 | 0:45ce241d316b | 74 | }; |
zh870524589 | 0:45ce241d316b | 75 | |
zh870524589 | 0:45ce241d316b | 76 | |
zh870524589 | 0:45ce241d316b | 77 | |
zh870524589 | 0:45ce241d316b | 78 | |
zh870524589 | 0:45ce241d316b | 79 | |
zh870524589 | 0:45ce241d316b | 80 | #endif |