A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.
Dependencies: ConfigFile N5110 PowerControl beep mbed
Diff: main.cpp
- Revision:
- 68:e978b6bccff8
- Parent:
- 67:3574ddf58be3
- Child:
- 69:a6eb73a1a571
--- a/main.cpp Fri May 08 06:18:04 2015 +0000 +++ b/main.cpp Fri May 08 07:30:43 2015 +0000 @@ -1044,14 +1044,13 @@ } } -///Implements Game. +///Begins Game. void game(int& exitFlag, int& exitOption) { actionButtons(); lcd.clear();//clears screen drawBackground();//draw background - - ///game/// + while(1) { //print score - top left of display char buffer[14];//create buffer for string @@ -1087,11 +1086,11 @@ int contactPoint = 0; //contact points - if(lcd.getPixel((a1+4),32)) + if(lcd.getPixel((a3),32)) contactPoint++; - if(lcd.getPixel((a1),32)) + if(lcd.getPixel((a3+3),32)) contactPoint++; - if(lcd.getPixel((a7),32)) + if(lcd.getPixel((a3-3),32)) contactPoint++; //if contact point is not zero @@ -1121,7 +1120,7 @@ lcd.refresh();//refresh screen startrek();//clears unset pixels, keeps set pixels -//Exit Menu (Back button pressed)/// +//Exit Menu (Back button pressed)// if(buttonFlagB) { //rightness(1.0); buttonFlagB = 0;//reset flags @@ -1145,8 +1144,7 @@ break; } //'exit' option NO - returns to game - if((buttonFlagA)&&(exitOption == 1)) { - //rightness(1.0); + if((buttonFlagA)&&(exitOption == 1)) { buttonFlagA = 0;//resets flags buttonFlagB = 0; break; @@ -1172,7 +1170,9 @@ lcd.clear();//clear screen drawBackground();//set background lcd.printString("High Scores",10,0);//title - + + read();//reads scores from file + //prints scores with names lcd.printString(player1initials,5,2);//display @@ -1331,14 +1331,11 @@ buttonA.mode(PullDown);//pull down buttonA buttonB.mode(PullDown);//pull down buttonB - - write();//write to memory - read();//read from memory int exitFlag = 0;//exit flag int mainOption = 0;//counter for main menu int exitOption = 1;//counter for exit menu - + timerA.attach(&timerExpiredA, 0.1);//checks state of buttonA timerB.attach(&timerExpiredB, 0.1);//checks state of buttonB @@ -1359,6 +1356,7 @@ } // if 'Scores' selected if((mainOption == 1)&&(buttonFlagA)) { + read(); buttonFlagA = 0; buttonFlagB = 0; scores();