![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Game for 4180 Lab4
Dependencies: 4DGL-uLCD-SE 4180_lab4_tank_war_game Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player
Dependents: 4180_lab4_tank_war_game
Tank/tank.h@0:ffed9a3bc797, 2017-03-13 (annotated)
- Committer:
- ychen644
- Date:
- Mon Mar 13 21:23:17 2017 +0000
- Revision:
- 0:ffed9a3bc797
Uploading 4180 Lab4 game to Notebook wiki
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ychen644 | 0:ffed9a3bc797 | 1 | #ifndef TANK_H__ |
ychen644 | 0:ffed9a3bc797 | 2 | #define TANK_H__ |
ychen644 | 0:ffed9a3bc797 | 3 | |
ychen644 | 0:ffed9a3bc797 | 4 | // This class describes a tank. You may need to add |
ychen644 | 0:ffed9a3bc797 | 5 | // additional member variables (and maybe even member functions) |
ychen644 | 0:ffed9a3bc797 | 6 | // to draw your super cool new tank. |
ychen644 | 0:ffed9a3bc797 | 7 | |
ychen644 | 0:ffed9a3bc797 | 8 | class Tank { |
ychen644 | 0:ffed9a3bc797 | 9 | public: |
ychen644 | 0:ffed9a3bc797 | 10 | |
ychen644 | 0:ffed9a3bc797 | 11 | int x, y; // Keep track of your tank's position. |
ychen644 | 0:ffed9a3bc797 | 12 | int w; // Tank width. |
ychen644 | 0:ffed9a3bc797 | 13 | int h; // Tank height. |
ychen644 | 0:ffed9a3bc797 | 14 | int tank_color; // Tank color. Duh :) |
ychen644 | 0:ffed9a3bc797 | 15 | float barrel_theta; // Barrel angle. |
ychen644 | 0:ffed9a3bc797 | 16 | int barrel_length; // Length of the barrel. |
ychen644 | 0:ffed9a3bc797 | 17 | int wheel_rad; // Radius of the wheels. |
ychen644 | 0:ffed9a3bc797 | 18 | |
ychen644 | 0:ffed9a3bc797 | 19 | int SKY_COLOR; // sky color |
ychen644 | 0:ffed9a3bc797 | 20 | |
ychen644 | 0:ffed9a3bc797 | 21 | // Construct a tank given its starting position (sx, sy), |
ychen644 | 0:ffed9a3bc797 | 22 | // its width and height, and its color. |
ychen644 | 0:ffed9a3bc797 | 23 | Tank(int sx, int sy, int width, int height, int color); |
ychen644 | 0:ffed9a3bc797 | 24 | |
ychen644 | 0:ffed9a3bc797 | 25 | // Calculate the bounding box of your tank for collision checking. |
ychen644 | 0:ffed9a3bc797 | 26 | int min_x(void); |
ychen644 | 0:ffed9a3bc797 | 27 | int min_y(void); |
ychen644 | 0:ffed9a3bc797 | 28 | int max_x(void); |
ychen644 | 0:ffed9a3bc797 | 29 | int max_y(void); |
ychen644 | 0:ffed9a3bc797 | 30 | |
ychen644 | 0:ffed9a3bc797 | 31 | // changeSky |
ychen644 | 0:ffed9a3bc797 | 32 | void changeSky(int SKY_COLOR2); |
ychen644 | 0:ffed9a3bc797 | 33 | |
ychen644 | 0:ffed9a3bc797 | 34 | // Calculate the position of the end of the barrel. |
ychen644 | 0:ffed9a3bc797 | 35 | void barrel_end(int* bx, int* by); |
ychen644 | 0:ffed9a3bc797 | 36 | |
ychen644 | 0:ffed9a3bc797 | 37 | // Reposition the tank! |
ychen644 | 0:ffed9a3bc797 | 38 | void reposition(int dx, int dy, float dtheta); |
ychen644 | 0:ffed9a3bc797 | 39 | |
ychen644 | 0:ffed9a3bc797 | 40 | // Draw the tank! |
ychen644 | 0:ffed9a3bc797 | 41 | void draw(); |
ychen644 | 0:ffed9a3bc797 | 42 | }; |
ychen644 | 0:ffed9a3bc797 | 43 | |
ychen644 | 0:ffed9a3bc797 | 44 | #endif |