ELEC2645 (2018/19) / Mbed 2 deprecated el17szs

Dependencies:   mbed

Revision:
21:a0904159e183
Parent:
20:9d21599fe350
Child:
22:69d7fe739872
Child:
24:23fd6b451db7
diff -r 9d21599fe350 -r a0904159e183 Bat/Bat.cpp
--- a/Bat/Bat.cpp	Tue Apr 30 10:27:23 2019 +0000
+++ b/Bat/Bat.cpp	Tue Apr 30 13:17:14 2019 +0000
@@ -16,7 +16,7 @@
     _x = 42;
     _y = 15;
     _hitBall=0;
-    _button_pressed=false;
+    
 }
 void Bat::reset(){
     _hitBall=0;
@@ -27,122 +27,12 @@
     lcd.drawRect(41,35,6,3,FILL_BLACK);
     //ball1.draw();
 }
-int Bat::get_hitBall(){
-    if (batPad.check_event(Gamepad::A_PRESSED) == true){
-        _hitBall=1;
-    }
+int Bat::get_hitBall(UX &ux){
+    _hitBall=ux.get_a_pressed();
+    printf("_hitBall %i \n",_hitBall);
     return _hitBall;
 }
-int Bat::get_loft_ball(){
-     if (batPad.check_event(Gamepad::L_PRESSED) == true){
-        //badPad.tone(750.0,0.1);
-        _loft_ball=1;
-    }
+int Bat::get_loft_ball(UX &ux){
+     _loft_ball=ux.get_a_pressed();
     return _loft_ball;
-}
-void Bat::first_menu(N5110 &menu_lcd,Gamepad &pad){
-    menu_lcd.clear();
-    menu_lcd.printString("HERO CRICKET",5,1);
-    menu_lcd.refresh();
-    menu_lcd.printString("game by el17szs",2,3);
-    wait(1);
-    menu_lcd.refresh();
-    menu_lcd.printString("PRESS START..",1,5);
-    wait(1);
-    menu_lcd.refresh();
-    while (batPad.check_event(Gamepad::START_PRESSED) == false) {
-            printf("2");
-            batPad.leds_on();
-            wait(0.1);
-            batPad.leds_off();
-            wait(0.1);
-        }
-        second_menu(menu_lcd);
-        batPad.leds_off();
-}
-void Bat::second_menu(N5110 &menu_lcd){
-    while (_button_pressed==false){
-        batPad.leds_off();
-        menu_lcd.clear();
-        menu_lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT);
-        menu_lcd.printString("START GAME",2,1);
-        menu_lcd.printString("A",70,1);
-        menu_lcd.drawCircle(72,11,5,FILL_TRANSPARENT);
-        menu_lcd.printString("RULES",2,3);
-        menu_lcd.printString("B",70,3);
-        menu_lcd.drawCircle(72,27,5,FILL_TRANSPARENT);
-        menu_lcd.printString("CONTROLS",2,5);
-        menu_lcd.printString("Y",70,5);
-        menu_lcd.drawCircle(72,42,5,FILL_TRANSPARENT);
-        menu_lcd.refresh();
-        if (batPad.check_event(Gamepad::A_PRESSED) == true){
-            _button_pressed=true;
-        }
-    }
-    
-}
-
-void Bat::game_over(string message){
-    //char buffer[14];
-    //int length=sprintf(buffer,"%s",message);
-    //menu_lcd.printString(buffer,3,1);
-}  
-
-void Bat::game_over_menu(N5110 &menu_lcd,int option){
-    if (option==1){
-        menu_lcd.clear();
-        menu_lcd.printString("GAME LOST",2,1);
-        menu_lcd.printString("NO MORE BALLS LEFT",2,3);
-        menu_lcd.refresh();
-        wait(5);
-    }
-    if (option==2){
-        menu_lcd.clear();
-        menu_lcd.printString("GAME LOST",2,1);
-        menu_lcd.printString("BOWLED",2,3);
-        menu_lcd.refresh();
-        wait(5);
-    }
-    if (option==3){
-        menu_lcd.clear();
-        menu_lcd.printString("GAME LOST",2,1);
-        menu_lcd.printString("CAUGHT",2,3);
-        menu_lcd.refresh();
-        wait(5);
-    }
-    
-}
-void Bat::victory_menu(N5110 &menu_lcd){
-    menu_lcd.clear();
-    menu_lcd.printString("CONGRATS!!",2,1);
-    menu_lcd.printString("YOU HAVE WON",2,3);
-    menu_lcd.refresh();
-    wait(5);
-}
-void Bat::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();
-    int i=0;
-    /*
-    while (i<=10){
-        batPad.leds_on();
-        wait(0.1);
-        batPad.leds_off();
-        wait(0.1);
-        i++;
-    }
-    */
-    wait(3);
-    
-}
-
+}
\ No newline at end of file