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:
8:82d88f9381f3
Parent:
7:e72691603fd3
Child:
9:fa7e7b37b632
--- a/LevelNormal.cpp	Sat Jun 08 16:44:54 2013 +0000
+++ b/LevelNormal.cpp	Sat Jun 08 17:51:33 2013 +0000
@@ -77,7 +77,7 @@
     // Kill off all player's bullets.
     player->KillAllBullets( gd );
     // Kill off all explosions.
-    // ExplosionManager::Instance.KillAllExplosions();
+    ExplosionManager::Instance.KillAllExplosions();
 }
 
 /**********************************/
@@ -126,7 +126,6 @@
 // Pass sprite number of sprite that it hit in spriteNumber.
 void LevelNormal::HandleHumanCollision( UInt8 humanIndex, UInt8 spriteNumber )
 {
-#if 0
     // Point to array of enemy object pointers.
     GameObject **enemies = currentInstance->DataForLevel->Enemies;
     EnemyObject *enemy;
@@ -143,8 +142,10 @@
             if( enemy->SquashesHumans ) {
                 // Change human to dead state.
                 human->CurrentState = HumanObject::Dead;
+                #if 0
                 // Make a noise.
                 SoundManager::Instance.PlaySound( Sounds::HumanDies, 0, 0 );
+                #endif
             } else if( enemy->GetEnemyType() == Brain ) {
                 // Kill human by inserting a null into humans array.
                 humans[ humanIndex ] = (GameObject*)NULL;
@@ -160,12 +161,11 @@
                     // TODO : SoundManager::Instance.PlaySound( Sounds::HumanMutates, 0, 0 );
                 } else {
                     // Could not find a free slot for a new enemy so just erase the human sprite.
-                    GDExtra::HideSprite( human->SpriteNumber );
+                    GDExtra::HideSprite( currentInstance->gd, human->SpriteNumber );
                 }
             }
         }
     }
-#endif
 }
 
 /********************************************************/
@@ -175,7 +175,6 @@
 // Pass sprite number of sprite that it hit in spriteNumber.
 void LevelNormal::HandleBulletCollision( UInt8 bulletIndex, UInt8 spriteNumber )
 {
-#if 0
     // Point to array of enemy object pointers.
     GameObject **enemies = currentInstance->DataForLevel->Enemies;
     EnemyObject *enemy;
@@ -191,7 +190,7 @@
                 // Kill enemy by inserting a NULL into enemies array.
                 enemies[ enemyIndex ] = (GameObject*)NULL;
                 // Hide the enemy sprite.
-                GDExtra::HideSprite( enemy->SpriteNumber );
+                GDExtra::HideSprite( currentInstance->gd, enemy->SpriteNumber );
                 // Add points to player's score.
                 currentInstance->player->AddToScore( enemy->GetPoints() );
             }
@@ -199,13 +198,14 @@
         // Tell enemy it has been hit by a bullet.
         enemy->RegisterHitByBullet();
         // Kill off the bullet.
-        currentInstance->player->KillBullet( bulletIndex );
+        currentInstance->player->KillBullet( currentInstance->gd, bulletIndex );
+        #if 0
         // Make a noise.
         SoundManager::Instance.PlaySound( Sounds::Explosion, 0, 0 );
+        #endif
         // Start explosion animation using coordinates of enemy.
         ExplosionManager::Instance.StartExplosion( enemy->Xco, enemy->Yco    );
     }
-#endif
 }
 
 /*********************************************************/
@@ -214,10 +214,9 @@
 // Pass pointer to a flag that will be set true if player is dead in isDead parameter.
 void LevelNormal::CheckPlayerCollisions( bool *isDead )
 {
-#if 0
     UInt8 enemyIndex, humanIndex;
     // Check if player sprite has hit another sprite.
-    UInt8 hitSpriteNumber = GD.rd( COLLISION + player->SpriteNumber );
+    UInt8 hitSpriteNumber = gd->rd( Gameduino::COLLISION + player->SpriteNumber );
     // If you get 0xFF then no collision found.
     if( hitSpriteNumber != 0xFF ) {
         // Check for collision with an enemy.
@@ -241,12 +240,13 @@
                 human->CurrentState = HumanObject::Rescued;
                 // Give player 50 points (in BCD!).
                 player->AddToScore( 0x50 );
+                #if 0
                 // Make a noise.
                 SoundManager::Instance.PlaySound( Sounds::RescueHuman, 0, 0 );
+                #endif
             }
         }
     }
-#endif
 }
 
 /***********************************************************************************/
@@ -307,22 +307,18 @@
             gd->waitvblank();
             // Check for collisions between player and other objects.
             CheckPlayerCollisions( &playerIsDead );
-#if 0
             // Check for collisions between humans and enemies that squash.
-            GameObject::FindCollisions( DataForLevel->Humans, LevelData::MaxHumans, &LevelNormal::HandleHumanCollision );
+            GameObject::FindCollisions( gd, DataForLevel->Humans, LevelData::MaxHumans, &LevelNormal::HandleHumanCollision );
             // Check for collisions between player bullets and enemies.
-            GameObject::FindCollisions( player->GetBullets(), BulletManager::MaxBullets, &LevelNormal::HandleBulletCollision );
-#endif
+            GameObject::FindCollisions( gd, player->GetBullets(), BulletManager::MaxBullets, &LevelNormal::HandleBulletCollision );
             // Redraw the player's score and number of lives.
             DrawScoreAndLives();
             // Draw all the enemies.
             GameObject::DrawAll( gd, DataForLevel->Enemies, LevelData::MaxEnemies );
-#if 0
             // Draw all the humans.
-            GameObject::DrawAll( DataForLevel->Humans, LevelData::MaxHumans );
+            GameObject::DrawAll( gd, DataForLevel->Humans, LevelData::MaxHumans );
             // Draw all the explosions.
-            GameObject::DrawAll( ExplosionManager::Instance.GetExplosions(), ExplosionManager::MaxExplosions );
-#endif
+            GameObject::DrawAll( gd, ExplosionManager::Instance.GetExplosions(), ExplosionManager::MaxExplosions );
             // Draw the player.
             player->Draw( gd );
             // Draw the player's bullets.
@@ -374,12 +370,10 @@
                         LevelData::MaxEnemies
                     );
                 }
-#if 0
                 // Move all the humans.
                 GameObject::MoveAll( DataForLevel->Humans, LevelData::MaxHumans );
                 // Move (update) all the explosions.
                 GameObject::MoveAll( ExplosionManager::Instance.GetExplosions(), ExplosionManager::MaxExplosions );
-#endif
                 // Read the player's controls.
                 player->ReadControls();
                 // Move the player.
@@ -396,4 +390,3 @@
         return Completed;
     }
 }
-