Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Bat/Bat.cpp
- Revision:
- 20:9d21599fe350
- Parent:
- 19:e1ded5acb64a
- Child:
- 21:a0904159e183
diff -r e1ded5acb64a -r 9d21599fe350 Bat/Bat.cpp
--- a/Bat/Bat.cpp Sat Apr 27 18:16:59 2019 +0000
+++ b/Bat/Bat.cpp Tue Apr 30 10:27:23 2019 +0000
@@ -16,6 +16,7 @@
_x = 42;
_y = 15;
_hitBall=0;
+ _button_pressed=false;
}
void Bat::reset(){
_hitBall=0;
@@ -39,7 +40,7 @@
}
return _loft_ball;
}
-void Bat::first_menu(N5110 &menu_lcd){
+void Bat::first_menu(N5110 &menu_lcd,Gamepad &pad){
menu_lcd.clear();
menu_lcd.printString("HERO CRICKET",5,1);
menu_lcd.refresh();
@@ -49,8 +50,6 @@
menu_lcd.printString("PRESS START..",1,5);
wait(1);
menu_lcd.refresh();
-
- menu_lcd.refresh();
while (batPad.check_event(Gamepad::START_PRESSED) == false) {
printf("2");
batPad.leds_on();
@@ -60,25 +59,26 @@
}
second_menu(menu_lcd);
batPad.leds_off();
-
-
-
}
void Bat::second_menu(N5110 &menu_lcd){
- 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();
+ 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;
+ }
+ }
}
@@ -121,17 +121,19 @@
}
void Bat::info_screen(N5110 &menu_lcd, int target){
menu_lcd.clear();
- menu_lcd.printString("YOU ARE GIVEN",0,0);
- menu_lcd.printString("10 BALLS ",3,1);
+ menu_lcd.printString("YOU ARE GIVEN",2,1);
+ menu_lcd.printString("10 BALLS ",3,2);
menu_lcd.refresh();
- wait(3);
- menu_lcd.clear();
+ wait(0.5);
char buffer[5];
int length=sprintf(buffer,"SCORE %i RUNS",target);
- menu_lcd.printString(buffer,0,1);
- menu_lcd.printString("GOOD LUCK!!!",0,4);
+ 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);
@@ -139,6 +141,7 @@
wait(0.1);
i++;
}
+ */
wait(3);
}