George Cochrane
/
ScoreCount
bad version
Revision 1:d41b5b18175b, committed 2013-05-01
- Comitter:
- gcme93
- Date:
- Wed May 01 14:45:59 2013 +0000
- Parent:
- 0:c82f950266fc
- Commit message:
- Life count down :)
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c82f950266fc -r d41b5b18175b main.cpp --- a/main.cpp Wed May 01 13:50:51 2013 +0000 +++ b/main.cpp Wed May 01 14:45:59 2013 +0000 @@ -5,7 +5,7 @@ int hit=0; -int lives=20; +int lives=10; float a; TSISensor tsi; @@ -16,16 +16,18 @@ + int main() { +Flash=1; +lcd.cls(); -lcd.cls(); while(1) { - while (lives>-1) + while (lives>0) { a=tsi.readPercentage(); @@ -35,28 +37,66 @@ else {hit=0;} - lcd.locate(0,0); lcd.printf("Lives remaining: %d \n", lives); if (hit==1) { + unsigned char i; + lives--; + lcd.locate(0,0); + lcd.printf("Lives remaining: %d \n", lives); - + for(i=0;i<4;i++) + { + Flash=0; + wait(0.2); + Flash=1; + wait(0.2); + } } - } + + while (lives==0) + { + a=tsi.readPercentage(); + + if (a>=0.01) + {hit=1;} + else + {hit=0;} + + lcd.locate(0,0); + lcd.printf("Lives remaining: %d \n", lives); + + + if (hit==1) + { + lives--; + } + } + + lcd.cls(); lcd.locate(0,0); lcd.printf(" - GAME OVER - ...you suck"); -wait(20); + +unsigned char i; +for(i=0;i<200;i++) + { + Flash=0; + wait(0.05); + Flash=1; + wait(0.05); + } + lcd.cls(); -lives=20; +lives= 10; } } \ No newline at end of file