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

Files at this revision

API Documentation at this revision

Comitter:
RichardE
Date:
Tue Jun 11 21:04:48 2013 +0000
Parent:
13:50779b12ff51
Child:
15:d8ea0c7b7e64
Commit message:
Started to modify how high scores are entered but not finished. Currently asks for a name when program first starts. Remove this code later.

Changed in this revision

CharBlocks.cpp Show annotated file Show diff for this revision Revisions of this file
CharBlocks.h Show annotated file Show diff for this revision Revisions of this file
GameRobotRic.cpp Show annotated file Show diff for this revision Revisions of this file
HighScoreEntry.cpp Show annotated file Show diff for this revision Revisions of this file
HighScoreEntry.h Show annotated file Show diff for this revision Revisions of this file
--- a/CharBlocks.cpp	Tue Jun 11 19:29:04 2013 +0000
+++ b/CharBlocks.cpp	Tue Jun 11 21:04:48 2013 +0000
@@ -1,33 +1,21 @@
-/*
- * SOURCE FILE : CharBlocks.cpp
- *
- * A collection of character block definitions.
- *
- */
-
-#include "CharBlocks.h"
-
-const UInt8 CharBlocks::RobotRicText[] = {
-    45, // section width
-    7, // section height
-    0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x0E, 0x02, 0x0B, 0x02, 0x10, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x0E, 0x0B, 0x10, 0x00, 0x01, 0x02, 0x02, 0x02, 0x10, // row 0
-    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 1
-    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 2
-    0x0A, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0A, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0A, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 3
-    0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 4
-    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 5
-    0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x06, 0x02, 0x02, 0x02, 0x08, 0x00, 0x06, 0x02, 0x02, 0x02, 0x08, 0x00, 0x06, 0x02, 0x02, 0x02, 0x08, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x0E, 0x0D, 0x10, 0x00, 0x06, 0x02, 0x02, 0x02, 0x10, // row 6
-};
+/*
+ * SOURCE FILE : CharBlocks.cpp
+ *
+ * A collection of character block definitions.
+ *
+ */
+
+#include "CharBlocks.h"
 
-const UInt8 CharBlocks::EnterNameInstructionText[] = {
-    47, // section width
-    7, // section height
-    0x20, 0x20, 0x20, 0x43, 0x4F, 0x4E, 0x47, 0x52, 0x41, 0x54, 0x55, 0x4C, 0x41, 0x54, 0x49, 0x4F, 0x4E, 0x53, 0x20, 0x3A, 0x20, 0x59, 0x4F, 0x55, 0x20, 0x48, 0x41, 0x56, 0x45, 0x20, 0x41, 0x20, 0x48, 0x49, 0x47, 0x48, 0x20, 0x53, 0x43, 0x4F, 0x52, 0x45, 0x21, 0x00, 0x00, 0x00, 0x00, // row 0
-    0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // row 1
-    0x50, 0x4C, 0x45, 0x41, 0x53, 0x45, 0x20, 0x45, 0x4E, 0x54, 0x45, 0x52, 0x20, 0x59, 0x4F, 0x55, 0x52, 0x20, 0x4E, 0x41, 0x4D, 0x45, 0x20, 0x55, 0x53, 0x49, 0x4E, 0x47, 0x20, 0x54, 0x48, 0x45, 0x20, 0x4C, 0x45, 0x46, 0x54, 0x20, 0x4A, 0x4F, 0x59, 0x53, 0x54, 0x49, 0x43, 0x4B, 0x2E, // row 2
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 3
-    0x20, 0x20, 0x55, 0x53, 0x45, 0x20, 0x44, 0x4F, 0x57, 0x4E, 0x20, 0x41, 0x4E, 0x44, 0x20, 0x55, 0x50, 0x20, 0x54, 0x4F, 0x20, 0x53, 0x45, 0x4C, 0x45, 0x43, 0x54, 0x20, 0x54, 0x48, 0x45, 0x20, 0x4E, 0x45, 0x58, 0x54, 0x20, 0x4C, 0x45, 0x54, 0x54, 0x45, 0x52, 0x2E, 0x20, 0x20, 0x20, // row 4
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // row 5
-    0x20, 0x20, 0x20, 0x20, 0x55, 0x53, 0x45, 0x20, 0x4C, 0x45, 0x46, 0x54, 0x20, 0x41, 0x4E, 0x44, 0x20, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x54, 0x4F, 0x20, 0x4D, 0x4F, 0x56, 0x45, 0x20, 0x54, 0x48, 0x45, 0x20, 0x43, 0x55, 0x52, 0x53, 0x4F, 0x52, 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, // row 6
-};
-
+const UInt8 CharBlocks::RobotRicText[] = {
+    45, // section width
+    7, // section height
+    0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x0E, 0x02, 0x0B, 0x02, 0x10, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x00, 0x0E, 0x0B, 0x10, 0x00, 0x01, 0x02, 0x02, 0x02, 0x10, // row 0
+    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 1
+    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 2
+    0x0A, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0A, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0A, 0x02, 0x02, 0x0B, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 3
+    0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 4
+    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, // row 5
+    0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x06, 0x02, 0x02, 0x02, 0x08, 0x00, 0x06, 0x02, 0x02, 0x02, 0x08, 0x00, 0x06, 0x02, 0x02, 0x02, 0x08, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x0E, 0x0D, 0x10, 0x00, 0x06, 0x02, 0x02, 0x02, 0x10, // row 6
+};
+
--- a/CharBlocks.h	Tue Jun 11 19:29:04 2013 +0000
+++ b/CharBlocks.h	Tue Jun 11 21:04:48 2013 +0000
@@ -1,26 +1,26 @@
-/*
- * SOURCE FILE : CharBlocks.h
- *
- * A collection of character block definitions.
- *
- */
-
-#ifndef CharBlocksIncluded
-  
-  #define CharBlocksIncluded
-
-  #include "Types.h"
-  
-  class CharBlocks {
-    
-  public :
-  
-    static const UInt8 RobotRicText[];              // big RobotRic logo
-        static const UInt8 EnterNameInstructionText[];    // instructions for entering name on high score table
-
-  };
-  
-#endif
-
-/* END of CharBlocks.h */
+/*
+ * SOURCE FILE : CharBlocks.h
+ *
+ * A collection of character block definitions.
+ *
+ */
+
+#ifndef CharBlocksIncluded
+  
+  #define CharBlocksIncluded
 
+  #include "Types.h"
+  
+  class CharBlocks {
+    
+  public :
+  
+    static const UInt8 RobotRicText[];              // big RobotRic logo
+
+  };
+  
+#endif
+
+/* END of CharBlocks.h */
+
+
--- a/GameRobotRic.cpp	Tue Jun 11 19:29:04 2013 +0000
+++ b/GameRobotRic.cpp	Tue Jun 11 21:04:48 2013 +0000
@@ -33,7 +33,7 @@
 void GameRobotRic::CheckForHighScore( Gameduino *gd, HighScoreTable *highScores, UInt32 score ) {
     UInt8 tablePos;
     // Enter name into high score table if score is high enough.
-    if( ( tablePos = highScores->GetPositionInTable( player.Score ) ) < highScores->GetCapacity() ) {
+    if( ( tablePos = highScores->GetPositionInTable( score ) ) < highScores->GetCapacity() ) {
         // Player has made it onto the high score table.
         // Get player to input name.
         HighScoreEntry nameGetter;
@@ -108,6 +108,11 @@
     // Restrict players movement.
     player.MovementRestricted = true;
     player.Bounds = &ArenaRectangle;
+    
+    // REMOVE THIS!
+    CheckForHighScore( &gd, &highScores, 0x10000 );
+    
+    
     // Repeat forever.
     while( true ) {
         // Get level specified by level number.
--- a/HighScoreEntry.cpp	Tue Jun 11 19:29:04 2013 +0000
+++ b/HighScoreEntry.cpp	Tue Jun 11 21:04:48 2013 +0000
@@ -141,8 +141,46 @@
   }
   // Draw border around screen.
   CharFrame::Draw( gd, 0, 0, VISIBLE_CHAR_WIDTH, VISIBLE_CHAR_HEIGHT );
-  // Draw logo.
-  GDExtra::WriteProgCharBlock( gd, 2, 2, CharBlocks::EnterNameInstructionText );
+  // Draw instructions.
+  gd->putstr( 2, 2,  "   CONGRATULATIONS : YOU HAVE A HIGH SCORE!" );
+  gd->putstr( 2, 4,  "PLEASE ENTER YOUR NAME USING THE LEFT JOYSTICK" );
+  gd->putstr( 2, 6,  " TO MOVE THE CURSOR. PRESS THE LEFT BUTTON TO" );
+  gd->putstr( 2, 8,  "  ENTER EACH LETTER. MOVE CURSOR TO FOOT OF" );
+  gd->putstr( 2, 10, " SCREEN AND PRESS LEFT BUTTON WHEN FINISHED." );
+  // Draw character grid.
+  DrawGrid( gd );
+}
+
+// Grid constants.
+#define GRIDX 5
+#define GRIDY 14
+#define GRIDCOLUMNS 20
+#define GRIDROWS 3
+#define GRIDCOLUMNSPACING 2
+#define GRIDROWSPACING 2
+
+/***************************/
+/* DRAW THE CHARACTER GRID */
+/***************************/
+// Pass pointer to Gameduino to draw on in gd.
+void HighScoreEntry::DrawGrid( Gameduino *gd ) {
+    UInt8 code = PlayerName::MinChar;
+    UInt8 x = GRIDX, y = GRIDY;
+    UInt8 columnNumber = 0;
+    char str [] = "X";
+    while( code <= PlayerName::MaxChar ) {
+        str[ 0 ] = (char)code++;
+        gd->putstr( x, y, str );
+        columnNumber++;
+        if( columnNumber >= GRIDCOLUMNS ) {
+            columnNumber = 0;
+            x = GRIDX;
+            y += GRIDROWSPACING;
+        }
+        else {
+            x += GRIDCOLUMNSPACING;
+        }
+    }
 }
 
 /********************************/
--- a/HighScoreEntry.h	Tue Jun 11 19:29:04 2013 +0000
+++ b/HighScoreEntry.h	Tue Jun 11 21:04:48 2013 +0000
@@ -57,6 +57,12 @@
     // Pass pointer to Gameduino to display on in gd.
     void DrawScreen( Gameduino *gd );    
 
+    /***************************/
+    /* DRAW THE CHARACTER GRID */
+    /***************************/
+    // Pass pointer to Gameduino to draw on in gd.
+    void DrawGrid( Gameduino *gd );
+
     /********************************/
     /* DRAW THE NAME AND THE CURSOR */
     /********************************/