The classic dueling tanks game for mbed.
Dependencies: 4DGL-uLCD-SE DRV2605 EthernetInterface Game_Synchronizer MMA8452 SDFileSystem SparkfunAnalogJoystick mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Bullet/bullet.cpp@22:3c68eea5a609, 2015-10-29 (annotated)
- Committer:
- jford38
- Date:
- Thu Oct 29 05:14:49 2015 +0000
- Revision:
- 22:3c68eea5a609
- Parent:
- 21:edfeb289b21f
- Child:
- 23:77049670cae6
The Shell for students to fill in to play their tanks game.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jford38 | 17:7bc7127782e4 | 1 | #include "uLCD_4DGL.h" |
jford38 | 15:4b27a3a95772 | 2 | #include "bullet.h" |
jford38 | 15:4b27a3a95772 | 3 | #include "game_synchronizer.h" |
jford38 | 20:6a58052b0140 | 4 | #include "misc.h" |
jford38 | 15:4b27a3a95772 | 5 | #include "math.h" |
jford38 | 15:4b27a3a95772 | 6 | |
jford38 | 15:4b27a3a95772 | 7 | extern Game_Synchronizer sync; |
jford38 | 15:4b27a3a95772 | 8 | |
jford38 | 22:3c68eea5a609 | 9 | // Initialize the bullet. Don't have to do much here. |
jford38 | 22:3c68eea5a609 | 10 | // Just set the speed. |
jford38 | 15:4b27a3a95772 | 11 | Bullet::Bullet(Tank* t) { |
jford38 | 15:4b27a3a95772 | 12 | tank = t; |
jford38 | 22:3c68eea5a609 | 13 | //speed = ???; |
jford38 | 15:4b27a3a95772 | 14 | in_flight = false; |
jford38 | 15:4b27a3a95772 | 15 | } |
jford38 | 22:3c68eea5a609 | 16 | |
jford38 | 22:3c68eea5a609 | 17 | // Set the in_flight flag. Initialize values needed for |
jford38 | 22:3c68eea5a609 | 18 | // the trajectory calculations. |
jford38 | 15:4b27a3a95772 | 19 | void Bullet::shoot(void) { |
jford38 | 15:4b27a3a95772 | 20 | } |
jford38 | 15:4b27a3a95772 | 21 | |
jford38 | 22:3c68eea5a609 | 22 | // If the bullet is in flight, calculate its new position |
jford38 | 22:3c68eea5a609 | 23 | // after a time delta dt. |
jford38 | 21:edfeb289b21f | 24 | void Bullet::update_position(float dt) { |
jford38 | 22:3c68eea5a609 | 25 | |
jford38 | 21:edfeb289b21f | 26 | } |
jford38 | 21:edfeb289b21f | 27 | |
jford38 | 21:edfeb289b21f | 28 | // return codes: |
jford38 | 21:edfeb289b21f | 29 | // BULLET_NO_COLLISION: no collision |
jford38 | 21:edfeb289b21f | 30 | // BULLET_OFF_SCREEN: off the side of the screen |
jford38 | 21:edfeb289b21f | 31 | // Otherwise, returns the color you've hit in 16bpp format. |
jford38 | 21:edfeb289b21f | 32 | |
jford38 | 21:edfeb289b21f | 33 | int Bullet::time_step(float dt) { |
jford38 | 22:3c68eea5a609 | 34 | // If the bullet hasn't hit anything, |
jford38 | 22:3c68eea5a609 | 35 | // redraw the bullet at its new location. |
jford38 | 22:3c68eea5a609 | 36 | // If it has hit something (obstacle, tank, edge of the screen), return |
jford38 | 22:3c68eea5a609 | 37 | // a descriptive error code. |
jford38 | 21:edfeb289b21f | 38 | } |