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 MYTANK_H
zh870524589 0:45ce241d316b 2 #define MYTANK_H
zh870524589 0:45ce241d316b 3
zh870524589 0:45ce241d316b 4 #include "list"
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 "vector"
zh870524589 0:45ce241d316b 10
zh870524589 0:45ce241d316b 11
zh870524589 0:45ce241d316b 12 /** MyTank Class
zh870524589 0:45ce241d316b 13 * @brief Create the player'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 class Bullet;
zh870524589 0:45ce241d316b 19
zh870524589 0:45ce241d316b 20 class ETank;
zh870524589 0:45ce241d316b 21
zh870524589 0:45ce241d316b 22
zh870524589 0:45ce241d316b 23 class MyTank
zh870524589 0:45ce241d316b 24 {
zh870524589 0:45ce241d316b 25 public:
zh870524589 0:45ce241d316b 26
zh870524589 0:45ce241d316b 27 /**Initializes the position and properties of the tank
zh870524589 0:45ce241d316b 28 *@param pad - Make the led light
zh870524589 0:45ce241d316b 29 *@param lcd - Initialize the lcd in private
zh870524589 0:45ce241d316b 30 */
zh870524589 0:45ce241d316b 31 void init(Gamepad &pad,N5110 &lcd) ;
zh870524589 0:45ce241d316b 32 /**change the position of tank
zh870524589 0:45ce241d316b 33 *@param x - the value of tank' x position
zh870524589 0:45ce241d316b 34 *@param y - the value of tank' y position
zh870524589 0:45ce241d316b 35 */
zh870524589 0:45ce241d316b 36 void setpos(int x, int y);
zh870524589 0:45ce241d316b 37 /**get the direction of tank
zh870524589 0:45ce241d316b 38 *@param pad - get the direction
zh870524589 0:45ce241d316b 39 */
zh870524589 0:45ce241d316b 40 void read_input(Gamepad &pad);
zh870524589 0:45ce241d316b 41 /**draw the tank
zh870524589 0:45ce241d316b 42 *@param lcd - Target Screen
zh870524589 0:45ce241d316b 43 */
zh870524589 0:45ce241d316b 44 void draw(N5110 &lcd);
zh870524589 0:45ce241d316b 45 /**update the tank
zh870524589 0:45ce241d316b 46 *@param etank - the enemy's tanks
zh870524589 0:45ce241d316b 47 */
zh870524589 0:45ce241d316b 48 void update(list<ETank*>&etank);
zh870524589 0:45ce241d316b 49 /**the attack of player
zh870524589 0:45ce241d316b 50 *@param lstBullets - the bullets of player's tank
zh870524589 0:45ce241d316b 51 *@param v - get the position of the player's tank
zh870524589 0:45ce241d316b 52 *@param pad - get the direction and check if the button pressed
zh870524589 0:45ce241d316b 53 *@param etank - the enemy's tanks
zh870524589 0:45ce241d316b 54 *@param num_tank - the number of enemy's tank
zh870524589 0:45ce241d316b 55 */
zh870524589 0:45ce241d316b 56 void attack(list<Bullet*>&lstBullets,Vector2D v,Gamepad &pad,N5110 &lcd,list<ETank*>&etank,int &num_tank);
zh870524589 0:45ce241d316b 57 /**HP-1*/
zh870524589 0:45ce241d316b 58 void subHP();
zh870524589 0:45ce241d316b 59 /** HP +1*/
zh870524589 0:45ce241d316b 60 void addHP();
zh870524589 0:45ce241d316b 61 /** for the shop :buy the HP
zh870524589 0:45ce241d316b 62 *@param pad - check if the button pressed
zh870524589 0:45ce241d316b 63 */
zh870524589 0:45ce241d316b 64 void setHP(Gamepad &pad);
zh870524589 0:45ce241d316b 65
zh870524589 2:867fdea920c1 66 /** Get the HP
zh870524589 2:867fdea920c1 67 *@return the HP
zh870524589 2:867fdea920c1 68 */
zh870524589 0:45ce241d316b 69 int MT_HP();
zh870524589 0:45ce241d316b 70
zh870524589 0:45ce241d316b 71 int totalHP;
zh870524589 0:45ce241d316b 72
zh870524589 0:45ce241d316b 73 int attack_gap; // Tank attack interval
zh870524589 0:45ce241d316b 74 Vector2D get_pos();
zh870524589 0:45ce241d316b 75 Direction get_direction();
zh870524589 0:45ce241d316b 76
zh870524589 0:45ce241d316b 77
zh870524589 0:45ce241d316b 78
zh870524589 0:45ce241d316b 79 private:
zh870524589 0:45ce241d316b 80 int _x;
zh870524589 0:45ce241d316b 81 int _y;
zh870524589 0:45ce241d316b 82 int HP;
zh870524589 0:45ce241d316b 83
zh870524589 0:45ce241d316b 84 int count;
zh870524589 0:45ce241d316b 85
zh870524589 0:45ce241d316b 86 N5110 lcd;
zh870524589 0:45ce241d316b 87 Direction _d;
zh870524589 0:45ce241d316b 88 Direction _pre_d;
zh870524589 0:45ce241d316b 89 /** Check the collision between player's tank and enemy's tanks
zh870524589 0:45ce241d316b 90 * @param etank - the enemy's tanks
zh870524589 0:45ce241d316b 91 */
zh870524589 0:45ce241d316b 92 void check_tank_collsion(list<ETank*>&etank);
zh870524589 0:45ce241d316b 93 /** Check the pixel around player's tank */
zh870524589 0:45ce241d316b 94 void check_pixel();
zh870524589 0:45ce241d316b 95 };
zh870524589 0:45ce241d316b 96
zh870524589 0:45ce241d316b 97 #endif