ELEC2645 (2018/19) / Mbed 2 deprecated el17mtu_

Dependencies:   mbed

Revision:
10:1c3bdbf2fe9f
Parent:
9:571f92b0211b
Child:
11:e29b173ccb27
--- a/ModeA/ModeA.cpp	Wed May 08 20:27:31 2019 +0000
+++ b/ModeA/ModeA.cpp	Wed May 08 23:29:53 2019 +0000
@@ -21,21 +21,23 @@
     
  void ModeA::initialise(N5110 &lcd)
  {
-      x_position = 12;
- y_position = 18;
-  speed = 1;
+    //variables for the square
+    x_position = 12;
+    y_position = 18;
+    speed = 0;
     gravity = 1;
-    
+    //variables for the bar
     screen_width = 80;
     bar_width = 10;
-    
     bar_speed = 2;
     
-
-            srand(time(NULL));
-        size_top = rand() % 15;
-       srand(time(NULL));
-       size_bottom = rand() % 15; 
+   //score = 1;
+    
+    //generating random sizes of the bar 
+    srand(time(NULL));
+    size_top = rand() % 15;
+    srand(time(NULL));
+    size_bottom = rand() % 15; 
    
      
  }
@@ -58,7 +60,7 @@
           
         }
         
-        if (y_position > 44) {
+        if (y_position > 48) {
                
                 lcd.clear();
           lcd.printString("GAME OVER",6,2);
@@ -152,16 +154,57 @@
          bar_width = 0;
          size_top = 0;
         size_bottom = 0;
+        
           
           
           
          wait(0.5);
                
-               }
+            
+                
+                }
+                   
+                   
+               
                
-     
+        //       if ((screen_width ==  x_position)&& (size_bottom <  (y_position - 6)))  {
+   //        
+   //    lcd.printString("GAME OVER",6,2);
+   //    lcd.printString("Press BACK",6,4);
+   //       pad.tone(2000.0,0.3);
+   //      lcd.refresh();
+   //    bar_speed = 0;
+   //      speed = 0;
+   //   gravity = 0;
+   //     y_position = 48;
+   //     bar_width = 0;
+    //     size_top = 0;
+     //   size_bottom = 0;
+        
+          
+          
+     //    
+     //   wait(0.5);
+               
+      //      }
+            
+           if ((screen_width ==  x_position)&& (size_top <  y_position)) {
+              score = 1;
+              lcd.clear();
+               char buffer[14]; 
+         sprintf(buffer,"% .2f ", score);
+          lcd.printString(buffer,2,2);
+          lcd.printString("Score =",1,1);
+          lcd.refresh(); 
+          wait(1.0);
+                
+               }
+   //  if ((screen_width ==  x_position)&& (size_bottom <  (y_position - 6))) {
+      
+   //   }
       
       screen_width = screen_width - bar_speed;
+     
       wait(0.1);