For Nikhil

Dependencies:   4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player

Fork of 2035_Tanks_Shell by ECE2035 Spring 2015 TA

Committer:
jford38
Date:
Fri Oct 30 08:54:10 2015 +0000
Revision:
23:77049670cae6
Parent:
22:3c68eea5a609
Child:
26:317310d660b2
Final final final version. Maybe. For now. Ugh.

Who changed what in which revision?

UserRevisionLine numberNew 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 23:77049670cae6 10 // Keep a pointer to this bullet's tank.
jford38 23:77049670cae6 11 // Set the speed, and default the bullet to not in_flight.
jford38 15:4b27a3a95772 12 Bullet::Bullet(Tank* t) {
jford38 15:4b27a3a95772 13 tank = t;
jford38 22:3c68eea5a609 14 //speed = ???;
jford38 15:4b27a3a95772 15 in_flight = false;
jford38 15:4b27a3a95772 16 }
jford38 22:3c68eea5a609 17
jford38 23:77049670cae6 18 // If in_flight, do nothing. Otherwise,
jford38 23:77049670cae6 19 // set the in_flight flag, and initialize values needed for
jford38 23:77049670cae6 20 // the trajectory calculations. (x0, y0), (vx0, vy0), time
jford38 23:77049670cae6 21 // Hint: tank->barrel_end(...) is useful here.
jford38 15:4b27a3a95772 22 void Bullet::shoot(void) {
jford38 23:77049670cae6 23 in_flight = true;
jford38 15:4b27a3a95772 24 }
jford38 15:4b27a3a95772 25
jford38 22:3c68eea5a609 26 // If the bullet is in flight, calculate its new position
jford38 22:3c68eea5a609 27 // after a time delta dt.
jford38 21:edfeb289b21f 28 void Bullet::update_position(float dt) {
jford38 22:3c68eea5a609 29
jford38 21:edfeb289b21f 30 }
jford38 21:edfeb289b21f 31
jford38 21:edfeb289b21f 32 int Bullet::time_step(float dt) {
jford38 22:3c68eea5a609 33 // If the bullet hasn't hit anything,
jford38 22:3c68eea5a609 34 // redraw the bullet at its new location.
jford38 23:77049670cae6 35 // If it has hit something (obstacle, tank, edge of the screen),
jford38 23:77049670cae6 36 // set the in_flight flag back to false and return
jford38 23:77049670cae6 37 // one of the following codes.
jford38 23:77049670cae6 38 //
jford38 23:77049670cae6 39 // return codes:
jford38 23:77049670cae6 40 // BULLET_NO_COLLISION: no collision
jford38 23:77049670cae6 41 // BULLET_OFF_SCREEN: off the side of the screen
jford38 23:77049670cae6 42 // Otherwise, return the color you've hit in 16bpp format.
jford38 21:edfeb289b21f 43 }