Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE DRV2605 EthernetInterface Game_Synchronizer MMA8452 SDFileSystem SparkfunAnalogJoystick mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Diff: Tank/tank.cpp
- Revision:
- 23:77049670cae6
- Parent:
- 22:3c68eea5a609
- Child:
- 25:b3c075a2f2c7
diff -r 3c68eea5a609 -r 77049670cae6 Tank/tank.cpp
--- a/Tank/tank.cpp Thu Oct 29 05:14:49 2015 +0000
+++ b/Tank/tank.cpp Fri Oct 30 08:54:10 2015 +0000
@@ -46,13 +46,17 @@
}
void Tank::reposition(int dx, int dy, float dtheta) {
- // Move the tank dx pixels in the x direction.
- // Move the tank dy pixels in the y direction.
- // Move the tank barrel by an angle dtheta. Don't allow it to go below parallel.
+ // Blank out the old tank position, and
+ // Move the tank dx pixels in the x direction.
+ // Move the tank dy pixels in the y direction.
+ // Move the tank barrel by an angle dtheta. Don't allow it to go below parallel.
- // Do collision detection to prevent the tank from hitting things.
+ // Do collision detection to prevent the tank from hitting things.
+ // (obstacles, side of the screen, other tanks, etc.)
}
+
+// Example tank draw function. We expect you to get creative on this one!
void Tank::draw() {
sync.line(x + w/2.0, y+h+wheel_rad, x + w/2.0 + barrel_length*cos(barrel_theta), y+h+wheel_rad + barrel_length*sin(barrel_theta), BLACK);
sync.filled_rectangle(x, y+wheel_rad, x+w, y+h+wheel_rad, tank_color);
