A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.

Dependencies:   ConfigFile N5110 PowerControl beep mbed

Files at this revision

API Documentation at this revision

Comitter:
el13drt
Date:
Mon Apr 20 23:34:42 2015 +0000
Parent:
31:da1a4875c404
Child:
33:bc730c9b4b1c
Commit message:
shifting problem

Changed in this revision

tower.h Show annotated file Show diff for this revision Revisions of this file
--- a/tower.h	Mon Apr 20 22:32:43 2015 +0000
+++ b/tower.h	Mon Apr 20 23:34:42 2015 +0000
@@ -51,8 +51,8 @@
 int score = 0;
 
 //high score details
-int highScore1 = 2;
-int highScore2 = 1;
+int highScore1 = 0;
+int highScore2 = 0;
 int highScore3 = 0;
 
 //player initials
@@ -867,10 +867,10 @@
 }
 
 // if any of the high scores are beaten, they are replaced.
-// player enters initials using struct
+// player enters initials using struct data members
 void newScore()
 {   
-    if(score >= highScore3) {//entry condition
+    if(score >= highScore3) {//entry condition for loop
 
         lcd.clear();
         backGround();
@@ -879,8 +879,6 @@
         int n;//local variable used for storing temporary global variable
         int initial = 0;//used for isolating which initial is being selected
 
-        //put conditions here
-
         while(1) {
 
             // joystick selection
@@ -915,7 +913,6 @@
                     serial.printf(" RIGHT\n");
                     initial = initial++;
                     if (initial > 2)initial = 2;
-                    
                 }
                 // Centre / Unknown orientation
                 if (joystick.direction == CENTRE)
@@ -928,41 +925,43 @@
             char y[1];//for initials
             char z[1];
 
-            // if initial 3 display selected character
+            // if initial = 0, row 1 is selected
             if (initial == 0) {
-                int initial1 = sprintf(x,"%c",fsm[state1].output1);//insert into letter in x
+                int initial0 = sprintf(x,"%c",fsm[state1].output1);//insert into letter in x
                 lcd.printString(x,25,26);//print x buffer
             }
-            // if initial 1 display selected character
+            // if initial = 1, row 2 is selected
             if(initial == 1) {
-                int initial2 = sprintf(y,"%c",fsm[state2].output2);//insert into letter in y
+                int initial1 = sprintf(y,"%c",fsm[state2].output2);//insert into letter in y
                 lcd.printString(y,37,26);//print y buffer
             }
-            // if initial 2 display selected character
+            // if initial = 2, row 3 is selected
             if(initial == 2) {
-                int initial3 = sprintf(z,"%c",fsm[state3].output3);//insert into letter z
+                int initial2 = sprintf(z,"%c",fsm[state3].output3);//insert into letter z
                 lcd.printString(z,49,26);//print z buffer
             }
             // if player beats High Score 3, replace it with new score
-            if(score >= highScore3 && score<highScore2 ) {
+            if((score >= highScore3) && (score<highScore2) ) {
                 n = score;
                 highScore3 = n;
-                //
+                //insert string into buffer player3initials
                 int insert3 = sprintf (player3initials, "3.%s%s%s....%i",x,y,z,highScore3);
             }
             // if player beats High Score 3 and 2, replace HighScore2 with new score
-            if(score >= highScore2 && score< highScore1) {
-                highScore3 = highScore2;
+            if((score >= highScore2) && (score< highScore1)) {
+                highScore3 = highScore2;//shift the score down
                 n = score;
                 highScore2 = n;
+                //insert string into buffer player2initials
                 int insert2 = sprintf (player2initials, "2.%s%s%s....%i",x,y,z,highScore2);
             }
             // if player beats High Score 1, 2 and 3, replace highScore1 with new score
             if(score >= highScore1 ) {
-                highScore3 = highScore2;
+                highScore3 = highScore2;//shift the scores down
                 highScore2 = highScore1;
                 n = score;
                 highScore1 = n;
+                //insert string into buffer player1initials
                 int insert1 = sprintf (player1initials, "1.%s%s%s....%i",x,y,z,highScore1);
             }
             // goes back to main menu after storing initials
@@ -971,6 +970,7 @@
                 buttonFlagB = 0;
                 break;
             }
+            sleep();
         }
     }
 }