![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Shell code for the Tanks game
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player
Diff: Bullet/bullet.cpp
- Revision:
- 19:7aa3af04d6a8
- Parent:
- 18:18dfc9fb33b5
- Child:
- 20:6a58052b0140
--- a/Bullet/bullet.cpp Wed Oct 28 06:36:24 2015 +0000 +++ b/Bullet/bullet.cpp Wed Oct 28 08:40:55 2015 +0000 @@ -22,18 +22,19 @@ } int Bullet::time_step(float dt) { - if(!in_flight) {return 0;} + if(!in_flight) {return CONVERT_24_TO_16_BPP(SKY_COLOR);} time += dt; int new_x = x0 + vx0*time; int new_y = y0 + vy0*time + 0.5*(-9.81)*time*time; if(new_x == x && new_y == y) { // Didn't move! - return 0; + return CONVERT_24_TO_16_BPP(SKY_COLOR); } if(new_x < 0 || new_x > 128 || new_y < 0 || new_y > 128) { + sync.pixel(x, y, SKY_COLOR); in_flight = false; - return 0; + return CONVERT_24_TO_16_BPP(BLACK); } int col = sync.read_pixel(new_x, new_y); @@ -43,19 +44,19 @@ in_flight = false; if(col == CONVERT_24_TO_16_BPP(TANK_BLUE)) { - return TANK_BLUE; + return col; } if( col == CONVERT_24_TO_16_BPP(TANK_RED)) { - return TANK_RED; + return col; } - return 0; + return CONVERT_24_TO_16_BPP(BLACK); } sync.pixel(x, y, SKY_COLOR); x = new_x; y = new_y; sync.pixel(x, y, BLACK); - return 0; + return CONVERT_24_TO_16_BPP(SKY_COLOR); }