Revenge of the Mouse

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

Fork of 2035_Tanks_Shell by ECE2035 Spring 2015 TA

Committer:
jford38
Date:
Thu Oct 29 03:56:30 2015 +0000
Revision:
21:edfeb289b21f
Parent:
17:7bc7127782e4
Final Version (I hope). Gonna start stripping out the code to make the shell I reckon.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jford38 15:4b27a3a95772 1 #ifndef BULLET_H__
jford38 15:4b27a3a95772 2 #define BULLET_H__
jford38 15:4b27a3a95772 3
jford38 15:4b27a3a95772 4 #include "tank.h"
jford38 15:4b27a3a95772 5
jford38 21:edfeb289b21f 6 #define BULLET_NO_COLLISION -1
jford38 21:edfeb289b21f 7 #define BULLET_OFF_SCREEN -2
jford38 21:edfeb289b21f 8
jford38 15:4b27a3a95772 9 class Bullet{
jford38 15:4b27a3a95772 10 public:
jford38 21:edfeb289b21f 11
jford38 21:edfeb289b21f 12 // (x0, y0) is the position of the bullet at the start of its trajectory.
jford38 21:edfeb289b21f 13 int x0, y0;
jford38 21:edfeb289b21f 14
jford38 21:edfeb289b21f 15 // The components of the bullet's initial velocity.
jford38 21:edfeb289b21f 16 float vx0, vy0;
jford38 21:edfeb289b21f 17
jford38 21:edfeb289b21f 18 // The current position of the bullet.
jford38 21:edfeb289b21f 19 int x, y;
jford38 21:edfeb289b21f 20
jford38 21:edfeb289b21f 21 // How fast is the bullet?
jford38 15:4b27a3a95772 22 int speed;
jford38 21:edfeb289b21f 23
jford38 21:edfeb289b21f 24 // Keep track of the time since the bullet was shot.
jford38 15:4b27a3a95772 25 float time;
jford38 21:edfeb289b21f 26
jford38 21:edfeb289b21f 27 // Keep track of whether the bullet is currently in flight.
jford38 21:edfeb289b21f 28 // If it is in_flight, update its position. Otherwise, ignore it.
jford38 21:edfeb289b21f 29 // Set in_flight when the bullet is shot.
jford38 21:edfeb289b21f 30 // Reset in_flight when the bullet hits something.
jford38 15:4b27a3a95772 31 bool in_flight;
jford38 15:4b27a3a95772 32
jford38 21:edfeb289b21f 33 // Keep a pointer to the tank that shot this bullet. You'll need
jford38 21:edfeb289b21f 34 // it to access information about the tank.
jford38 15:4b27a3a95772 35 Tank* tank;
jford38 15:4b27a3a95772 36
jford38 21:edfeb289b21f 37 // Create a bullet!
jford38 15:4b27a3a95772 38 Bullet(Tank* t);
jford38 21:edfeb289b21f 39
jford38 21:edfeb289b21f 40 // Shoot the bullet!
jford38 15:4b27a3a95772 41 void shoot(void);
jford38 21:edfeb289b21f 42
jford38 21:edfeb289b21f 43 // given a time delta, calculate the new (x, y) coords of the bullet.
jford38 21:edfeb289b21f 44 void update_position(float dt);
jford38 21:edfeb289b21f 45
jford38 21:edfeb289b21f 46 // Once per frame, plug in the time since the last frame.
jford38 21:edfeb289b21f 47 // Clear the old bullet and redraw it in the new place.
jford38 21:edfeb289b21f 48 // Do collision detection here. Return a code describing what has
jford38 21:edfeb289b21f 49 // (or hasn't) been hit.
jford38 15:4b27a3a95772 50 int time_step(float dt);
jford38 15:4b27a3a95772 51 };
jford38 15:4b27a3a95772 52
jford38 15:4b27a3a95772 53 #endif