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.
Diff: main.cpp
- Revision:
- 133:05bb8de3c630
- Parent:
- 132:a98cfea2d292
- Child:
- 134:48c4b408868c
--- a/main.cpp Thu May 09 08:45:03 2019 +0000
+++ b/main.cpp Thu May 09 09:02:23 2019 +0000
@@ -144,11 +144,13 @@
lcd.printString("HI-SCORE: ",0,5);
print_hi_score(55,5);
lcd.refresh();
- wait(0.3); // load initial frame (delay helps button bounce)
+ wait(0.3); // load initial frame
+
+ pad.reset_flags(); // fixes button bounce?
int pointer = 1;
- while (pad.check_event(Gamepad::A_PRESSED)) {
+ while (pad.check_event(Gamepad::A_PRESSED) == false) {
lcd.clear();
lcd.printString(" START ",0,1); // start game with default as joystick
lcd.printString(" SETTINGS ",0,2); // choose between joystick and tilt
@@ -196,6 +198,8 @@
lcd.drawRect(42,30,40 * pad.read_pot() + 1,10,FILL_BLACK); // represents the sensitivity which is changed by turning the pot
lcd.refresh();
wait(0.1);
+
+ pad.reset_flags(); // fixes button bounce?
int pointer = 1; // init the pointer
@@ -251,6 +255,8 @@
arrowdown.render(lcd, 38, 43);
lcd.refresh();
wait(0.1); // load initial frame
+
+ pad.reset_flags(); // fixes button bounce?
while (pad.check_event(Gamepad::B_PRESSED) == false) { // while B is not pressed to return to main menu, display instruction on how to interact with the game
@@ -281,7 +287,9 @@
void main_game() // the Game loop
-{
+{
+ pad.reset_flags(); // fixes button bounce?
+
int fps = 8; // frames per second
bool pause = false; // set pause screen to false
//printf("Pause = %d",pointer);
@@ -304,6 +312,7 @@
}
if (pad.check_event(Gamepad::START_PRESSED)) { // if BACK pressed, toggle pause
pause = !pause;
+ pad.reset_flags(); // fixes button bounce?
}
while (pause == true) { // if pause is true, display pause screen
@@ -312,6 +321,7 @@
lcd.printString(" START = PLAY",0,3);
lcd.printString(" BACK = MENU",0,4);
lcd.refresh();
+ wait(0.1);
if (pad.check_event(Gamepad::START_PRESSED)) { // if START pressed, toggle pause, leaving pause screen
pause = !pause;
}