![](/media/cache/profiles/004acbc8eefec9fe0629b15f52b94bcf.50x50_q85.jpg)
Peter's version
Fork of ScoreCount by
Diff: main.cpp
- Revision:
- 1:d41b5b18175b
- Parent:
- 0:c82f950266fc
- Child:
- 2:289c6ccc4e86
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