For Nikhil
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Tank/tank.h@21:edfeb289b21f, 2015-10-29 (annotated)
- Committer:
- jford38
- Date:
- Thu Oct 29 03:56:30 2015 +0000
- Revision:
- 21:edfeb289b21f
- Parent:
- 14:36c306e26317
- Child:
- 22:3c68eea5a609
Final Version (I hope). Gonna start stripping out the code to make the shell I reckon.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jford38 | 14:36c306e26317 | 1 | #ifndef TANK_H__ |
jford38 | 14:36c306e26317 | 2 | #define TANK_H__ |
jford38 | 14:36c306e26317 | 3 | |
jford38 | 14:36c306e26317 | 4 | |
jford38 | 14:36c306e26317 | 5 | class Tank { |
jford38 | 14:36c306e26317 | 6 | public: |
jford38 | 21:edfeb289b21f | 7 | |
jford38 | 21:edfeb289b21f | 8 | int x, y; // Keep track of your tank's position. |
jford38 | 21:edfeb289b21f | 9 | int w; // Tank width. |
jford38 | 21:edfeb289b21f | 10 | int h; // Tank height. |
jford38 | 21:edfeb289b21f | 11 | int tank_color; // Tank color. Duh :) |
jford38 | 21:edfeb289b21f | 12 | float barrel_theta; // Barrel angle. |
jford38 | 21:edfeb289b21f | 13 | int barrel_length; // Length of the barrel. |
jford38 | 21:edfeb289b21f | 14 | int wheel_rad; // Radius of the wheels. |
jford38 | 14:36c306e26317 | 15 | |
jford38 | 14:36c306e26317 | 16 | |
jford38 | 21:edfeb289b21f | 17 | // Construct a tank given its starting position (sx, sy), |
jford38 | 21:edfeb289b21f | 18 | // its width and height, and its color. |
jford38 | 14:36c306e26317 | 19 | Tank(int sx, int sy, int width, int height, int color); |
jford38 | 21:edfeb289b21f | 20 | |
jford38 | 21:edfeb289b21f | 21 | // Calculate the bounding box of your tank for collision checking. |
jford38 | 14:36c306e26317 | 22 | int min_x(void); |
jford38 | 14:36c306e26317 | 23 | int min_y(void); |
jford38 | 14:36c306e26317 | 24 | int max_x(void); |
jford38 | 14:36c306e26317 | 25 | int max_y(void); |
jford38 | 14:36c306e26317 | 26 | |
jford38 | 21:edfeb289b21f | 27 | // Calculate the position of the end of the barrel. |
jford38 | 14:36c306e26317 | 28 | void barrel_end(int& bx, int& by); |
jford38 | 14:36c306e26317 | 29 | |
jford38 | 21:edfeb289b21f | 30 | // Reposition the tank! |
jford38 | 21:edfeb289b21f | 31 | void reposition(int dx, int dy, float dtheta); |
jford38 | 21:edfeb289b21f | 32 | |
jford38 | 21:edfeb289b21f | 33 | // Draw the tank! |
jford38 | 14:36c306e26317 | 34 | void draw(); |
jford38 | 14:36c306e26317 | 35 | }; |
jford38 | 14:36c306e26317 | 36 | |
jford38 | 14:36c306e26317 | 37 | #endif |