A retro gaming programme, designed for use on a portable embedded system. Incorporates power saving techniques.
Dependencies: ConfigFile N5110 PowerControl beep mbed
Revision 59:be7a31cb8cd1, committed 2015-05-02
- Comitter:
- el13drt
- Date:
- Sat May 02 02:39:30 2015 +0000
- Parent:
- 58:1111619f7cf3
- Child:
- 60:681bc941b94d
- Commit message:
- final 3:39 2/5/15
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
tower.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat May 02 02:25:45 2015 +0000 +++ b/main.cpp Sat May 02 02:39:30 2015 +0000 @@ -25,8 +25,7 @@ } //read file -void read() -{ +void read(){ char *key = "Open";//check key matches //check file-if read unsuccessful print error message @@ -213,14 +212,6 @@ wait(0.6); } -//initial head movement values -int h1 = a3-1; -int h2 = a3-3; -int h3 = a3+4; -int h4 = a3+3; -int h5 = a3+2; -int h6 = a3+1; - //pixel ninja character void drawNinja() { @@ -230,6 +221,12 @@ lcd.drawRect(a2,39,0,7,1); //centre stick lcd.drawRect(a3,37,0,7,1); + //back of the head + lcd.drawRect(a1,33,0,4,1); + //top of the head + lcd.drawRect(a1,33,4,0,1); + //jaw + lcd.drawRect(a2,38,2,0,1); //right shoulder lcd.drawRect(a4,40,1,0,1); //left shoulder @@ -238,23 +235,16 @@ lcd.drawRect(a5,41,0,1,1); //right arm lcd.drawRect(a6,41,0,1,1); - //right eye - lcd.drawRect(h1,35,0,0,1); + lcd.drawRect(a6,35,0,0,1); //mouth piece - lcd.drawRect(h2,37,0,0,1); + lcd.drawRect(a6,37,0,0,1); //left eye - lcd.drawRect(h2,35,0,0,1); + lcd.drawRect(a2,35,0,0,1); //sword handle - lcd.drawRect(h3,36,0,0,1); - lcd.drawRect(h4,37,0,0,1); - lcd.drawRect(h5,38,0,0,1); - //back of the head - lcd.drawRect(h6,33,0,4,1); - //top of the head - lcd.drawRect(h2,33,4,0,1); - //jaw - lcd.drawRect(h2,38,2,0,1); + lcd.drawRect(a7,36,0,0,1); + lcd.drawRect(a5,37,0,0,1); + lcd.drawRect(a8,38,0,0,1); lcd.refresh(); } @@ -272,12 +262,12 @@ a3 = 76; if(a1 > 75) a1 = 75; - // if(a8 > 74) -// a8 = 74; + if(a8 > 74) + a8 = 74; if(a5 > 73) a5 = 73; -// if(a7 > 72) -// a7 = 72; + if(a7 > 72) + a7 = 72; if(a6 < 11 ) a6 = 11; @@ -289,12 +279,12 @@ a3 = 8; if(a1 < 7) a1 = 7; - //if(a8 < 6) -// a8 = 6; + if(a8 < 6) + a8 = 6; if(a5 < 5) a5 = 5; - // if(a7 < 4) -// a7 = 4; + if(a7 < 4) + a7 = 4; } //resets variables initial values when game ends or is exited @@ -308,8 +298,8 @@ a4 = 25; a5 = 20; a6 = 26; -// a7 = 19; -// a8 = 21; + a7 = 19; + a8 = 21; //in this case the X values are given a //new random variable each time the player @@ -975,34 +965,8 @@ a4 = a4-=2; a5 = a5-=2; a6 = a6-=2; - - h1 = a3-3; - h2 = a3+3; - h3 = a3-4; - h4 = a3-3; - h5 = a3-2; - h6 = a3-1; - - // a7 = a7-=2; -// a8 = a8-=2; - -// //right eye -// lcd.drawRect((a3-1),35,0,0,1); -// //mouth piece -// lcd.drawRect((a3-3),37,0,0,1); -// //left eye -// lcd.drawRect((a3-3),35,0,0,1); -// //sword handle -// lcd.drawRect((a3+4),36,0,0,1); -// lcd.drawRect((a3+3),37,0,0,1); -// lcd.drawRect((a3+2),38,0,0,1); -// //back of the head -// lcd.drawRect((a3+1),33,0,4,1); -// //top of the head -// lcd.drawRect((a3-3),33,4,0,1); -// //jaw -// lcd.drawRect((a3-3),38,2,0,1); - + a7 = a7-=2; + a8 = a8-=2; ninjaBoundaries(); } if (joystick.direction == RIGHT) { @@ -1013,35 +977,8 @@ a4 = a4+=2; a5 = a5+=2; a6 = a6+=2; - - h1 = a3-1; - h2 = a3-3; - h3 = a3+4; - h4 = a3+3; - h5 = a3+2; - h6 = a3+1; - - - // a7 = a7+=2; -// a8 = a8+=2; - -// //right eye -// lcd.drawRect((a3+3),35,0,0,1); -// //mouth piece -// lcd.drawRect((a3+3),37,0,0,1); -// //left eye -// lcd.drawRect((a3+1),35,0,0,1); -// //sword handle -// lcd.drawRect((a3-4),36,0,0,1); -// lcd.drawRect((a3-3),37,0,0,1); -// lcd.drawRect((a3-2),38,0,0,1); -// //back of the head -// lcd.drawRect((a3-1),33,0,4,1); -// //top of the head -// lcd.drawRect((a3-1),33,4,0,1); -// //jaw -// lcd.drawRect((a3+1),38,2,0,1); - + a7 = a7+=2; + a8 = a8+=2; ninjaBoundaries(); } if (joystick.direction == CENTRE) @@ -1058,7 +995,7 @@ contactPoint++; if(lcd.getPixel((a1),32)) contactPoint++; - if(lcd.getPixel((a3-3),32)) + if(lcd.getPixel((a7),32)) contactPoint++; //if contact point is not zero @@ -1284,7 +1221,7 @@ timerA.attach(&timerExpiredA, 0.1);//checks state of buttonA timerB.attach(&timerExpiredB, 0.1);//checks state of buttonB - + while(1) { drawMainMenu();//draws main menu mainMenu(mainOption);//presents main menu options
--- a/tower.h Sat May 02 02:25:45 2015 +0000 +++ b/tower.h Sat May 02 02:39:30 2015 +0000 @@ -75,8 +75,8 @@ int a4 = 25; int a5 = 20; int a6 = 26; -//int a7 = 19; -//int a8 = 21; +int a7 = 19; +int a8 = 21; //global variable for hazard X co-ordinates int randX1;