George Cochrane
/
ScoreCount
bad version
main.cpp
- Committer:
- gcme93
- Date:
- 2013-05-01
- Revision:
- 1:d41b5b18175b
- Parent:
- 0:c82f950266fc
File content as of revision 1:d41b5b18175b:
#include "mbed.h" #include "TSISensor.h" #include "TextLCD.h" int hit=0; int lives=10; float a; TSISensor tsi; DigitalOut Flash(PTC11); TextLCD lcd(PTD7, PTD6, PTA17, PTA16, PTC17, PTC16); // rs, e, d4-d7 int main() { Flash=1; lcd.cls(); while(1) { 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) { 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"); unsigned char i; for(i=0;i<200;i++) { Flash=0; wait(0.05); Flash=1; wait(0.05); } lcd.cls(); lives= 10; } }