HaoZhang SID: 201199702

Dependencies:   mbed

Committer:
zh870524589
Date:
Thu May 14 17:45:05 2020 +0000
Revision:
2:867fdea920c1
Parent:
1:47fadd485c70
final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zh870524589 0:45ce241d316b 1 #ifndef ETANK_H
zh870524589 0:45ce241d316b 2 #define ETANK_H
zh870524589 0:45ce241d316b 3
zh870524589 0:45ce241d316b 4 #include "time.h"
zh870524589 0:45ce241d316b 5 #include "mbed.h"
zh870524589 0:45ce241d316b 6 #include "N5110.h"
zh870524589 0:45ce241d316b 7 #include "Gamepad.h"
zh870524589 0:45ce241d316b 8 #include "Bullet.h"
zh870524589 0:45ce241d316b 9 #include "list"
zh870524589 0:45ce241d316b 10 #include "vector"
zh870524589 0:45ce241d316b 11
zh870524589 0:45ce241d316b 12 /** ETank Class
zh870524589 0:45ce241d316b 13 * @brief Create the enemy's tank and set the tank behavior and properties
zh870524589 0:45ce241d316b 14 * @author HaoZhang
zh870524589 0:45ce241d316b 15 * @date May, 2020
zh870524589 0:45ce241d316b 16 */
zh870524589 0:45ce241d316b 17
zh870524589 0:45ce241d316b 18
zh870524589 0:45ce241d316b 19 class Bullet;
zh870524589 0:45ce241d316b 20
zh870524589 0:45ce241d316b 21 class MyTank;
zh870524589 0:45ce241d316b 22
zh870524589 0:45ce241d316b 23 class ETank
zh870524589 0:45ce241d316b 24 {
zh870524589 0:45ce241d316b 25
zh870524589 0:45ce241d316b 26 public:
zh870524589 0:45ce241d316b 27 /** Constructor
zh870524589 2:867fdea920c1 28 *@param lcd - Target Screen
zh870524589 2:867fdea920c1 29 *@param pad - set the tone when the tank create
zh870524589 0:45ce241d316b 30 */
zh870524589 0:45ce241d316b 31 ETank(N5110 &lcd,Gamepad &pad);
zh870524589 0:45ce241d316b 32 /** Destructor */
zh870524589 0:45ce241d316b 33 ~ETank();
zh870524589 0:45ce241d316b 34 /**change the position of tank
zh870524589 2:867fdea920c1 35 *@param x - the value of tank' x position
zh870524589 2:867fdea920c1 36 *@param y - the value of tank' y position
zh870524589 0:45ce241d316b 37 */
zh870524589 0:45ce241d316b 38 void setpos(int x, int y);
zh870524589 0:45ce241d316b 39 /**draw the tank
zh870524589 0:45ce241d316b 40 *@param lcd - Target Screen
zh870524589 0:45ce241d316b 41 */
zh870524589 0:45ce241d316b 42 void drawE(N5110 &lcd);
zh870524589 0:45ce241d316b 43 /**set the direction of tank
zh870524589 0:45ce241d316b 44 @param mt - player's tank
zh870524589 0:45ce241d316b 45 */
zh870524589 0:45ce241d316b 46 void direction(MyTank &mt);
zh870524589 0:45ce241d316b 47 /**update the tank
zh870524589 0:45ce241d316b 48 *@param lcd - Target Screen
zh870524589 0:45ce241d316b 49 *@param mt - player's tank
zh870524589 0:45ce241d316b 50 *@param etank - the bullets of enemy's tank
zh870524589 0:45ce241d316b 51 */
zh870524589 0:45ce241d316b 52 void update(N5110 &lcd,MyTank &mt,list<ETank*>&etank);
zh870524589 0:45ce241d316b 53 /**the attack of enemy's tank
zh870524589 2:867fdea920c1 54 *@param v - get the position of the player's tank
zh870524589 2:867fdea920c1 55 *@param pad - get the direction
zh870524589 2:867fdea920c1 56 *@param mtbullet - the bullets of player's tank
zh870524589 2:867fdea920c1 57 *@param et_attack - The threshold that an attack needs to reach
zh870524589 2:867fdea920c1 58 *@param timegap - Attack interval
zh870524589 2:867fdea920c1 59 */
zh870524589 0:45ce241d316b 60 void attack(Vector2D v,Gamepad &pad,N5110 &lcd,MyTank &mt,list<Bullet*> &mtbullet,int et_attack,int timegap);
zh870524589 0:45ce241d316b 61 /** Store the bullets */
zh870524589 0:45ce241d316b 62 list<Bullet*> lstBullets;
zh870524589 0:45ce241d316b 63
zh870524589 0:45ce241d316b 64 Vector2D get_pos();
zh870524589 0:45ce241d316b 65
zh870524589 0:45ce241d316b 66 private:
zh870524589 0:45ce241d316b 67 int _x;
zh870524589 0:45ce241d316b 68 int _y;
zh870524589 0:45ce241d316b 69 int count;
zh870524589 0:45ce241d316b 70 int MT_HP;
zh870524589 0:45ce241d316b 71 Direction _d;
zh870524589 0:45ce241d316b 72 /** Check the collision between player's tank and enemy's tanks
zh870524589 0:45ce241d316b 73 *@param lcd - Target Screen
zh870524589 0:45ce241d316b 74 *@param mt - the player's tanks
zh870524589 0:45ce241d316b 75 */
zh870524589 0:45ce241d316b 76 void check_tank_collsion(N5110&lcd,MyTank &mt);
zh870524589 0:45ce241d316b 77 /** Check the collision among enemy's tanks
zh870524589 0:45ce241d316b 78 *@param etank - the enemy's tanks
zh870524589 0:45ce241d316b 79 */
zh870524589 0:45ce241d316b 80 void check_self_collsion(list<ETank*>&etank);
zh870524589 0:45ce241d316b 81 /** Check the pixel around player's tank */
zh870524589 0:45ce241d316b 82 void check_pixel(N5110 &lcd);
zh870524589 0:45ce241d316b 83 /** The template of checking the collision
zh870524589 0:45ce241d316b 84 *@param t1- tank1
zh870524589 0:45ce241d316b 85 *@param t2- tank2
zh870524589 0:45ce241d316b 86 *@return Whether or not there is a collision
zh870524589 0:45ce241d316b 87 */
zh870524589 0:45ce241d316b 88 bool collsion_check(Vector2D t1,Vector2D t2);
zh870524589 0:45ce241d316b 89 };
zh870524589 0:45ce241d316b 90
zh870524589 0:45ce241d316b 91
zh870524589 0:45ce241d316b 92 #endif