Peter's version

Fork of ScoreCount by George Cochrane

Revision:
5:a50e02fc49cd
Parent:
4:7cec137649a0
Child:
6:e269f6c282bc
diff -r 7cec137649a0 -r a50e02fc49cd main.cpp
--- a/main.cpp	Thu May 02 16:07:04 2013 +0000
+++ b/main.cpp	Thu May 02 21:18:42 2013 +0000
@@ -4,7 +4,7 @@
 #include "process_signal.h"
 #include "reciever.h"
 
-TSISensor tsi;
+
 
 
 //RGB LED SETUP
@@ -29,49 +29,39 @@
 
 int main() 
 {
-
-
-
-
 while(1) 
-{
-    
-    
-    reset_array();  //At start of new game reset hits from players to 0
+{    
+    reset_array();          //At start of new game reset hits from players to 0
     
     while (lives>=0)
     {
-    Blue=1;     //Blue light always on when playing
-    Red=0;      //Red light off when no hits registered
+    Blue=1;                 //Blue light always on when playing
+    Red=0;                  
     Green=0;
     
     if (lives==0)
     {
-    Green=1;      //Magenta if no lives remain
+    Green=1;               //Turquoise if no lives remain (effectively last life left)
     }
     
-    //Print no. of lives
+    
     lcd.cls();
     
     lcd.locate(0,0);
-    lcd.printf("Player %c \n", Player);
+    lcd.printf("Player %c \n", Player);          //Print which player you are
     
     lcd.locate(0,1);
-    lcd.printf("Lives left: %d \n", lives);
+    lcd.printf("Lives left: %d \n", lives);      //Print how many lives are left
     
 
     //Have you been hit?
     
-    int signal;                                     //Signal input here!
-    
+    int signal;                                    
     signal=Interrogate();
-    
     hit= process_signal(signal);
 
                 if (hit==1)
-                {
-                unsigned char i;
-                   
+                {  
                 lives--;
                 
                 if(lives<0)
@@ -80,14 +70,13 @@
                 }
                 
                 //Update lives on LCD
-                lcd.locate(0,0);
-                lcd.printf("Player %c", Player);
                 
                 lcd.locate(0,1);
                 lcd.printf("You've been hit!");
                 
                 //Flash to register hit
-                for(i=0;i<4;i++)            //INCREASE i TO EXTEND TIME THAT GUN IS DISABLED! Maybe later add that being hit disables your own trigger?
+                unsigned char i;                
+                for(i=0;i<4;i++)            //INCREASE i TO EXTEND TIME THAT GUN IS DISABLED!
                     {
                     Blue=0;
                     Red=1;
@@ -97,9 +86,8 @@
                     wait(0.2);                  
                     }
                 }
-    
     }
-    
+       
 end:
 
 Blue=0;
@@ -110,7 +98,7 @@
 
 
 unsigned char i;
-for(i=0;i<50;i++)           //Flashing to indicate game over - INCREASE i FOR LONGER BREAK BEFORE RESET (perhaps button to reset, not auto reset?)
+for(i=0;i<50;i++)           //Flashing to indicate game over - INCREASE i FOR LONGER BREAK BEFORE RESET 
                     {
                     Red=1;
                     wait(0.05);