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

Revision:
5:0b0651ac7832
Parent:
4:673eb9735d44
--- a/BulletManager.cpp	Sat Jun 08 11:24:05 2013 +0000
+++ b/BulletManager.cpp	Sat Jun 08 14:40:47 2013 +0000
@@ -6,8 +6,8 @@
  */
 
 #include "BulletManager.h"
-// #include "BulletObject.h"
-// #include "ArenaConst.h"
+#include "BulletObject.h"
+#include "ArenaConst.h"
 #include "GDExtra.h"
 
 /***************/
@@ -16,7 +16,6 @@
 // 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 ) {
@@ -25,8 +24,9 @@
     bullet->PixelWidth = 6;
     bullet->PixelHeight = 6;
     bullet->Bounds = &ArenaRectangle;
+    // Make sure entry in bulletPointers array is NULL.
+    bulletPointers[ b ] = (GameObject*)NULL;
   }
-#endif
 }
 
 /**********************/
@@ -36,7 +36,6 @@
 // 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 ) ) {
@@ -50,32 +49,28 @@
     // No free bullet slots.
     return false;
   }
-#else
-return false;
-#endif
 }
 
 /************************/
 /* KILL A SINGLE BULLET */
 /************************/
+// Pass pointer to Gameduino that displays bullets in gd.
 // Pass index of bullet in b.
-void BulletManager::KillBullet( UInt8 b ) {
-#if 0
+void BulletManager::KillBullet( Gameduino *gd, UInt8 b ) {
     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 );
+      GDExtra::HideSprite( gd, bullet->SpriteNumber );
     }
-#endif
 }
 
 /********************/
 /* KILL ALL BULLETS */
 /********************/
-void BulletManager::KillAllBullets( void ) {
+// Pass pointer to Gameduino that displays bullets in gd.
+void BulletManager::KillAllBullets( Gameduino *gd ) {
   for( UInt8 b = 0; b < MaxBullets; ++b ) {
-    KillBullet( b );
+    KillBullet( gd, b );
   }
 }
-