Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.

Dependencies:   25LCxxx_SPI CommonTypes Gameduino mbed

Committer:
RichardE
Date:
Sat Jun 08 11:24:05 2013 +0000
Revision:
4:673eb9735d44
Child:
5:0b0651ac7832
Pulled in more code. Now panel controls are working. Level 0 (attract mode) now goes round an endless loop sending state of panel controls up serial port to PC.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RichardE 4:673eb9735d44 1 /*
RichardE 4:673eb9735d44 2 * SOURCE FILE : BulletManager.cpp
RichardE 4:673eb9735d44 3 *
RichardE 4:673eb9735d44 4 * Responsible for managing a collection of bullets.
RichardE 4:673eb9735d44 5 *
RichardE 4:673eb9735d44 6 */
RichardE 4:673eb9735d44 7
RichardE 4:673eb9735d44 8 #include "BulletManager.h"
RichardE 4:673eb9735d44 9 // #include "BulletObject.h"
RichardE 4:673eb9735d44 10 // #include "ArenaConst.h"
RichardE 4:673eb9735d44 11 #include "GDExtra.h"
RichardE 4:673eb9735d44 12
RichardE 4:673eb9735d44 13 /***************/
RichardE 4:673eb9735d44 14 /* CONSTRUCTOR */
RichardE 4:673eb9735d44 15 /***************/
RichardE 4:673eb9735d44 16 // Pass number of sprite to use for first bullet.
RichardE 4:673eb9735d44 17 // MaxBullets consequtive sprites will be used for bullets.
RichardE 4:673eb9735d44 18 BulletManager::BulletManager( UInt8 firstSpriteNumber ) {
RichardE 4:673eb9735d44 19 #if 0
RichardE 4:673eb9735d44 20 // Initialise aspects of bullets that never change.
RichardE 4:673eb9735d44 21 BulletObject *bullet;
RichardE 4:673eb9735d44 22 for( UInt8 b = 0; b < MaxBullets; ++b ) {
RichardE 4:673eb9735d44 23 bullet = bullets + b;
RichardE 4:673eb9735d44 24 bullet->SpriteNumber = firstSpriteNumber + b;
RichardE 4:673eb9735d44 25 bullet->PixelWidth = 6;
RichardE 4:673eb9735d44 26 bullet->PixelHeight = 6;
RichardE 4:673eb9735d44 27 bullet->Bounds = &ArenaRectangle;
RichardE 4:673eb9735d44 28 }
RichardE 4:673eb9735d44 29 #endif
RichardE 4:673eb9735d44 30 }
RichardE 4:673eb9735d44 31
RichardE 4:673eb9735d44 32 /**********************/
RichardE 4:673eb9735d44 33 /* START A BULLET OFF */
RichardE 4:673eb9735d44 34 /**********************/
RichardE 4:673eb9735d44 35 // Pass start coordinates in x and y (NOT pixel coordinates).
RichardE 4:673eb9735d44 36 // Pass bullet velocities in hv and vv (NOT pixel velocities).
RichardE 4:673eb9735d44 37 // Returns true if bullet was started successfully.
RichardE 4:673eb9735d44 38 bool BulletManager::StartBullet( Int16 x, Int16 y, Int16 hv, Int16 vv ) {
RichardE 4:673eb9735d44 39 #if 0
RichardE 4:673eb9735d44 40 // Try and find an unused bullet slot.
RichardE 4:673eb9735d44 41 UInt8 index;
RichardE 4:673eb9735d44 42 if( GameObject::FindUnusedObject( bulletPointers, MaxBullets, &index ) ) {
RichardE 4:673eb9735d44 43 // Found a free bullet slot. Point to entry in bullets array.
RichardE 4:673eb9735d44 44 BulletObject *bullet = bullets + index;
RichardE 4:673eb9735d44 45 bulletPointers[ index ] = bullet;
RichardE 4:673eb9735d44 46 bullet->Start( x, y, hv, vv );
RichardE 4:673eb9735d44 47 return true;
RichardE 4:673eb9735d44 48 }
RichardE 4:673eb9735d44 49 else {
RichardE 4:673eb9735d44 50 // No free bullet slots.
RichardE 4:673eb9735d44 51 return false;
RichardE 4:673eb9735d44 52 }
RichardE 4:673eb9735d44 53 #else
RichardE 4:673eb9735d44 54 return false;
RichardE 4:673eb9735d44 55 #endif
RichardE 4:673eb9735d44 56 }
RichardE 4:673eb9735d44 57
RichardE 4:673eb9735d44 58 /************************/
RichardE 4:673eb9735d44 59 /* KILL A SINGLE BULLET */
RichardE 4:673eb9735d44 60 /************************/
RichardE 4:673eb9735d44 61 // Pass index of bullet in b.
RichardE 4:673eb9735d44 62 void BulletManager::KillBullet( UInt8 b ) {
RichardE 4:673eb9735d44 63 #if 0
RichardE 4:673eb9735d44 64 GameObject *bullet = bulletPointers[ b ];
RichardE 4:673eb9735d44 65 if( bullet != (GameObject*)NULL ) {
RichardE 4:673eb9735d44 66 bulletPointers[ b ] = (BulletObject*)NULL;
RichardE 4:673eb9735d44 67 // Hide bullet sprite by setting y coordinate to 400.
RichardE 4:673eb9735d44 68 GDExtra::HideSprite( bullet->SpriteNumber );
RichardE 4:673eb9735d44 69 }
RichardE 4:673eb9735d44 70 #endif
RichardE 4:673eb9735d44 71 }
RichardE 4:673eb9735d44 72
RichardE 4:673eb9735d44 73 /********************/
RichardE 4:673eb9735d44 74 /* KILL ALL BULLETS */
RichardE 4:673eb9735d44 75 /********************/
RichardE 4:673eb9735d44 76 void BulletManager::KillAllBullets( void ) {
RichardE 4:673eb9735d44 77 for( UInt8 b = 0; b < MaxBullets; ++b ) {
RichardE 4:673eb9735d44 78 KillBullet( b );
RichardE 4:673eb9735d44 79 }
RichardE 4:673eb9735d44 80 }
RichardE 4:673eb9735d44 81