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
Diff: BulletManager.cpp
- Revision:
- 4:673eb9735d44
- Child:
- 5:0b0651ac7832
diff -r a6a0cd726ca0 -r 673eb9735d44 BulletManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BulletManager.cpp Sat Jun 08 11:24:05 2013 +0000 @@ -0,0 +1,81 @@ +/* + * 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 ); + } +} +