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
BulletManager.cpp
- Committer:
- RichardE
- Date:
- 2013-06-08
- Revision:
- 4:673eb9735d44
- Child:
- 5:0b0651ac7832
File content as of revision 4:673eb9735d44:
/* * SOURCE FILE : BulletManager.cpp * * Responsible for managing a collection of bullets. * */ #include "BulletManager.h" // #include "BulletObject.h" // #include "ArenaConst.h" #include "GDExtra.h" /***************/ /* CONSTRUCTOR */ /***************/ // Pass number of sprite to use for first bullet. // MaxBullets consequtive sprites will be used for bullets. BulletManager::BulletManager( UInt8 firstSpriteNumber ) { #if 0 // Initialise aspects of bullets that never change. BulletObject *bullet; for( UInt8 b = 0; b < MaxBullets; ++b ) { bullet = bullets + b; bullet->SpriteNumber = firstSpriteNumber + b; bullet->PixelWidth = 6; bullet->PixelHeight = 6; bullet->Bounds = &ArenaRectangle; } #endif } /**********************/ /* START A BULLET OFF */ /**********************/ // Pass start coordinates in x and y (NOT pixel coordinates). // Pass bullet velocities in hv and vv (NOT pixel velocities). // Returns true if bullet was started successfully. bool BulletManager::StartBullet( Int16 x, Int16 y, Int16 hv, Int16 vv ) { #if 0 // Try and find an unused bullet slot. UInt8 index; if( GameObject::FindUnusedObject( bulletPointers, MaxBullets, &index ) ) { // Found a free bullet slot. Point to entry in bullets array. BulletObject *bullet = bullets + index; bulletPointers[ index ] = bullet; bullet->Start( x, y, hv, vv ); return true; } else { // No free bullet slots. return false; } #else return false; #endif } /************************/ /* KILL A SINGLE BULLET */ /************************/ // Pass index of bullet in b. void BulletManager::KillBullet( UInt8 b ) { #if 0 GameObject *bullet = bulletPointers[ b ]; if( bullet != (GameObject*)NULL ) { bulletPointers[ b ] = (BulletObject*)NULL; // Hide bullet sprite by setting y coordinate to 400. GDExtra::HideSprite( bullet->SpriteNumber ); } #endif } /********************/ /* KILL ALL BULLETS */ /********************/ void BulletManager::KillAllBullets( void ) { for( UInt8 b = 0; b < MaxBullets; ++b ) { KillBullet( b ); } }