ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Revision:
31:eefa1d23a843
Parent:
30:43aace0fdbdf
Child:
33:9d34ef219fff
--- a/UserInteraction/UX.cpp	Wed May 08 01:20:06 2019 +0000
+++ b/UserInteraction/UX.cpp	Wed May 08 12:13:28 2019 +0000
@@ -10,7 +10,7 @@
 //Initialises the UX Object
 void UX::init()
 {
-    batPad.init();
+    _bat_pad.init();
   _button_pressed=false;
 }
 //Resets the button_pressed variable to ensure screen is printed again
@@ -20,7 +20,7 @@
 /*Checks if A Button is pressed to indicate if the ball is hit during the gameplay*/
 int UX::get_a_pressed(){
   int _a_pressed=0;
-  if (batPad.check_event(Gamepad::A_PRESSED) == true){
+  if (_bat_pad.check_event(Gamepad::A_PRESSED) == true){
     _a_pressed=1;
   }
   return _a_pressed;
@@ -28,7 +28,7 @@
 /*Checks if L Button is pressed to indicate if the ball hit is lofted during the gameplay*/
 int UX::get_l_pressed(){
   int _l_pressed=0;
-  if (batPad.check_event(Gamepad::L_PRESSED) == true){
+  if (_bat_pad.check_event(Gamepad::L_PRESSED) == true){
     _l_pressed=1;
   }
   return _l_pressed;
@@ -45,15 +45,15 @@
   menu_lcd.printString("PRESS START..",1,5);
   wait(1);
   menu_lcd.refresh();
-  while (batPad.check_event(Gamepad::START_PRESSED) == false) {
+  while (_bat_pad.check_event(Gamepad::START_PRESSED) == false) {
     printf("2");
-    batPad.leds_on();
+    _bat_pad.leds_on();
     wait(0.1);
-    batPad.leds_off();
+    _bat_pad.leds_off();
     wait(0.1);
   }
   second_menu(menu_lcd);
-  batPad.leds_off();
+  _bat_pad.leds_off();
 }
 /*
   The second menu is called at the start of the game and each time a game is over
@@ -64,20 +64,20 @@
   menu_lcd.setContrast(0.5);
   while (_button_pressed==false){
     menu_options(menu_lcd);
-    if (batPad.check_event(Gamepad::A_PRESSED) == true){
+    if (_bat_pad.check_event(Gamepad::A_PRESSED) == true){
       _button_pressed=true;
     }
-    if (batPad.check_event(Gamepad::B_PRESSED) == true){
+    if (_bat_pad.check_event(Gamepad::B_PRESSED) == true){
       rules_menu(menu_lcd);
     }
-    if (batPad.check_event(Gamepad::X_PRESSED) == true){
+    if (_bat_pad.check_event(Gamepad::X_PRESSED) == true){
       controls_menu(menu_lcd);    
     }
   }
 }
 /*Prints the options for the second menu onto the screen */
 void UX::menu_options(N5110 &menu_lcd){
-  batPad.leds_off();
+  _bat_pad.leds_off();
   menu_lcd.clear();
   menu_lcd.setContrast(0.5);
   menu_lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT);
@@ -107,8 +107,8 @@
   menu_lcd.printString("printed bottom ",0,1);
   menu_lcd.printString("left of LCD",0,2);
   menu_lcd.printString("Balls and Runs",0,3);
-  menu_lcd.printString("on top left",0,4);
-  menu_lcd.printString("and right",0,5);
+  menu_lcd.printString("on top Right",0,4);
+  menu_lcd.printString("and Left",0,5);
   menu_lcd.refresh();
   wait(5);
   menu_lcd.clear();
@@ -125,7 +125,7 @@
   menu_lcd.setContrast(0.5);
   menu_lcd.printString("Hit the ball",0,0);
   menu_lcd.printString("to score runs",0,1);
-  menu_lcd.printString("Ball is bolwed",0,3);
+  menu_lcd.printString("Ball is bowled",0,3);
   menu_lcd.printString("with a tone",0,4);
   menu_lcd.refresh();
   wait(5);
@@ -133,7 +133,7 @@
   menu_lcd.setContrast(0.5);
   menu_lcd.printString("There are 5",0,0);
   menu_lcd.printString("fielders in",0,1);
-  menu_lcd.printString("the ",0,1);
+  menu_lcd.printString("the outfield ",0,2);
   menu_lcd.printString("marked by",0,3);
   menu_lcd.printString("white circles",0,4);
   menu_lcd.refresh();
@@ -254,18 +254,3 @@
   menu_lcd.refresh();
   wait(5);
 }
-void UX::info_screen(N5110 &menu_lcd, int target){
-  menu_lcd.clear();
-  menu_lcd.printString("YOU ARE GIVEN",2,1);
-  menu_lcd.printString("10 BALLS ",3,2);
-  menu_lcd.refresh();
-  wait(0.5);
-  char buffer[5];
-  int length=sprintf(buffer,"SCORE %i RUNS",target);
-  menu_lcd.printString(buffer,2,4);
-  menu_lcd.refresh();
-  wait(0.5);
-  menu_lcd.printString("GOOD LUCK!!!",0,5);
-  menu_lcd.refresh();
-  wait(3);
-}