A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.
Dependencies: ConfigFile N5110 PowerControl beep mbed
Diff: tower.h
- Revision:
- 33:bc730c9b4b1c
- Parent:
- 32:f714d0993772
- Child:
- 34:9dc844bdc776
--- a/tower.h Mon Apr 20 23:34:42 2015 +0000 +++ b/tower.h Mon Apr 20 23:46:32 2015 +0000 @@ -51,8 +51,8 @@ int score = 0; //high score details -int highScore1 = 0; -int highScore2 = 0; +int highScore1 = 2; +int highScore2 = 1; 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 data members +// player enters initials using struct void newScore() { - if(score >= highScore3) {//entry condition for loop + if(score >= highScore3) {//entry condition lcd.clear(); backGround(); @@ -879,6 +879,8 @@ 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 @@ -913,6 +915,7 @@ serial.printf(" RIGHT\n"); initial = initial++; if (initial > 2)initial = 2; + } // Centre / Unknown orientation if (joystick.direction == CENTRE) @@ -925,43 +928,41 @@ char y[1];//for initials char z[1]; - // if initial = 0, row 1 is selected + // if initial 3 display selected character if (initial == 0) { - int initial0 = sprintf(x,"%c",fsm[state1].output1);//insert into letter in x + int initial1 = sprintf(x,"%c",fsm[state1].output1);//insert into letter in x lcd.printString(x,25,26);//print x buffer } - // if initial = 1, row 2 is selected + // if initial 1 display selected character if(initial == 1) { - int initial1 = sprintf(y,"%c",fsm[state2].output2);//insert into letter in y + int initial2 = sprintf(y,"%c",fsm[state2].output2);//insert into letter in y lcd.printString(y,37,26);//print y buffer } - // if initial = 2, row 3 is selected + // if initial 2 display selected character if(initial == 2) { - int initial2 = sprintf(z,"%c",fsm[state3].output3);//insert into letter z + int initial3 = 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;//shift the score down + if(score >= highScore2 && score< highScore1) { + highScore3 = highScore2; 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;//shift the scores down + highScore3 = highScore2; 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 @@ -970,7 +971,6 @@ buttonFlagB = 0; break; } - sleep(); } } }