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:
12:81926431fea7
Parent:
11:2ddaf46e95cb
--- a/LevelCollection.cpp	Sun Jun 09 19:58:49 2013 +0000
+++ b/LevelCollection.cpp	Mon Jun 10 20:02:28 2013 +0000
@@ -36,36 +36,54 @@
 // Not a real level. This is attract mode.
 static Level0 level0;
 
-// Level descriptors.
-static const UInt8 ld0[] = { ENDDESCRIPTOR };
-static const UInt8 ld1[] = { Grunt, 5, Crusher, 5, ENDDESCRIPTOR };
-static const UInt8 ld2[] = { Grunt, 10, Brain, 2, ENDDESCRIPTOR };
-static const UInt8 ld3[] = { Grunt, 10, Crusher, 8, ENDDESCRIPTOR };
-static const UInt8 ld4[] = { Grunt, 12, Crusher, 6, Brain, 2, ENDDESCRIPTOR };
-static const UInt8 ld5[] = { Grunt, 12, Brain, 4, BlueMeany, 2, ENDDESCRIPTOR };
-static const UInt8 ld6[] = { Grunt, 5, Crusher, 8, Brain, 1, BlueMeany, 3, ENDDESCRIPTOR };
-static const UInt8 ld7[] = { Brain, 15, ENDDESCRIPTOR };
-static const UInt8 ld8[] = { Grunt, 3, Brain, 2, BlueMeany, 5, ENDDESCRIPTOR };
-static const UInt8 ld9[] = { Grunt, 1, BlueMeany, 10, ENDDESCRIPTOR };
-static const UInt8 ld10[] = { Brain, 5, BlueMeany, 10, ENDDESCRIPTOR };
-static const UInt8 ld11[] = { Grunt, 5, Crusher, 5, Brain, 10, ENDDESCRIPTOR };
-static const UInt8 ld12[] = { Grunt, 10, Brain, 5, BlueMeany, 9, ENDDESCRIPTOR };
-static const UInt8 ld13[] = { BlueMeany, 15, ENDDESCRIPTOR };
-static const UInt8 ld14[] = { Brain, 20, ENDDESCRIPTOR };
-static const UInt8 ld15[] = { Grunt, 32, BlueMeany, 1, ENDDESCRIPTOR };
-static const UInt8 ld16[] = { Grunt, 10, Crusher, 30, ENDDESCRIPTOR };
-static const UInt8 ld17[] = { Brain, 25, ENDDESCRIPTOR };
-static const UInt8 ld18[] = { Grunt, 16, Brain, 16, ENDDESCRIPTOR };
-static const UInt8 ld19[] = { Grunt, 16, Brain, 16, BlueMeany, 5, ENDDESCRIPTOR };
-static const UInt8 ld20[] = { Brain, 15, BlueMeany, 15, ENDDESCRIPTOR };
+// Data for enemies on each level.
+static const UInt8 e0 [] = { ENDDESCRIPTOR };
+static const UInt8 e1 [] = { Grunt, 5, Crusher, 5, ENDDESCRIPTOR };
+static const UInt8 e2 [] = { Grunt, 10, Brain, 2, ENDDESCRIPTOR };
+static const UInt8 e3 [] = { Grunt, 10, Crusher, 8, ENDDESCRIPTOR };
+static const UInt8 e4 [] = { Grunt, 12, Crusher, 6, Brain, 2, ENDDESCRIPTOR };
+static const UInt8 e5 [] = { Grunt, 12, Brain, 4, BlueMeany, 2, ENDDESCRIPTOR };
+static const UInt8 e6 [] = { Grunt, 5, Crusher, 8, Brain, 1, BlueMeany, 3, ENDDESCRIPTOR };
+static const UInt8 e7 [] = { Brain, 15, ENDDESCRIPTOR };
+static const UInt8 e8 [] = { Grunt, 3, Brain, 2, BlueMeany, 5, ENDDESCRIPTOR };
+static const UInt8 e9 [] = { Grunt, 1, BlueMeany, 10, ENDDESCRIPTOR };
+static const UInt8 e10 [] = { Brain, 5, BlueMeany, 10, ENDDESCRIPTOR };
+static const UInt8 e11 [] = { Grunt, 5, Crusher, 5, Brain, 10, ENDDESCRIPTOR };
+static const UInt8 e12 [] = { Grunt, 10, Brain, 5, BlueMeany, 9, ENDDESCRIPTOR };
+static const UInt8 e13 [] = { BlueMeany, 15, ENDDESCRIPTOR };
+static const UInt8 e14 [] = { Brain, 20, ENDDESCRIPTOR };
+static const UInt8 e15 [] = { Grunt, 32, BlueMeany, 1, ENDDESCRIPTOR };
+static const UInt8 e16 [] = { Grunt, 10, Crusher, 30, ENDDESCRIPTOR };
+static const UInt8 e17 [] = { Brain, 25, ENDDESCRIPTOR };
+static const UInt8 e18 [] = { Grunt, 16, Brain, 16, ENDDESCRIPTOR };
+static const UInt8 e19 [] = { Grunt, 16, Brain, 16, BlueMeany, 5, ENDDESCRIPTOR };
+static const UInt8 e20 [] = { Brain, 15, BlueMeany, 15, ENDDESCRIPTOR };
 
-// Array pointing to level data for each level.
-static const UInt8* const levelDescriptors[ LEVELCOUNT ] = {
-    ld0, ld1, ld2, ld3, ld4,
-    ld5, ld6, ld7, ld8, ld9,
-    ld10, ld11, ld12, ld13, ld14,
-    ld15, ld16, ld17, ld18, ld19,
-    ld20,
+// Array containing level data for each level.
+// First parameter is number of humans.
+// Second parameter points to an array describing enemies on the level.
+static const LevelDescriptor levelDescriptors[ LEVELCOUNT ] = {
+    LevelDescriptor( 0, e0 ),
+    LevelDescriptor( 5, e1 ),
+    LevelDescriptor( 6, e2 ),
+    LevelDescriptor( 5, e3 ),
+    LevelDescriptor( 6, e4 ),
+    LevelDescriptor( 8, e5 ),
+    LevelDescriptor( 8, e6 ),
+    LevelDescriptor( 8, e7 ),
+    LevelDescriptor( 8, e8 ),
+    LevelDescriptor( 8, e9 ),
+    LevelDescriptor( 8, e10 ),
+    LevelDescriptor( 8, e11 ),
+    LevelDescriptor( 8, e12 ),
+    LevelDescriptor( 12, e13 ),
+    LevelDescriptor( 8, e14 ),
+    LevelDescriptor( 16, e15 ),
+    LevelDescriptor( 16, e16 ),
+    LevelDescriptor( 16, e17 ),
+    LevelDescriptor( 16, e18 ),
+    LevelDescriptor( 16, e19 ),
+    LevelDescriptor( 24, e20 ),
 };
 
 /***************/
@@ -84,7 +102,7 @@
   }
   else {
     // Fetch level descriptor for this level and create a Level from it.
-    Level *level = new LevelNormal( levelDescriptors[ levelNumber ] );
+    Level *level = new LevelNormal( levelDescriptors + levelNumber );
     // Tag it with the correct level number before returning it.
     level->LevelNumber = levelNumber;
     return level;