Dependencies: mbed
Diff: main.cpp
- Revision:
- 43:1ac200335a68
- Parent:
- 42:816e444e660b
diff -r 816e444e660b -r 1ac200335a68 main.cpp --- a/main.cpp Tue May 26 13:10:12 2020 +0000 +++ b/main.cpp Tue May 26 15:13:10 2020 +0000 @@ -135,7 +135,7 @@ void game_over(int level) //game over menu function { lcd.clear(); - + pad.leds_on(); while(1){ lcd.printString(" Game Over",0,0); //display game over and level until player resets game char buffer_[14]; @@ -161,13 +161,13 @@ { _difficulty = 1; //initialise difficulty to 1 bool select_ = false; //initialise select flag to false - - while(select_ == false){ - lcd.clear(); + //select flag indicates if A has been pressed + while(select_ == false){ //run loop while A has not yet been pressed (i.e. a selection has not yet been made) + lcd.clear(); //prints difficulty options on screen lcd.printString(" Easy",0,0); lcd.printString(" Medium",0,2); lcd.printString(" Hard",0,4); - switch (_difficulty){ + switch (_difficulty){ //switch to draw selection box next to the difficulty the player is currently hovering over case 1: lcd.drawRect(0,0,3,3,FILL_BLACK); break; @@ -179,40 +179,40 @@ break; } lcd.refresh(); - wait(1); + wait(1); //wait statement reduces sensitivity of switch making it usable while(1){ direction = pad.get_direction(); - if(pad.A_pressed()==true){ + if(pad.A_pressed()==true){ //set select flag to true if A is pressed select_ = true; break; } - if((_difficulty==1)&& + if((_difficulty==1)&& //if player is hovering over easy and moves joystick up then hover over hard (direction==N)){ _difficulty = 3; break; } - if((_difficulty==1)&& + if((_difficulty==1)&& //if player is hovering over easy and moves joystick down then hover over medium (direction==S)){ _difficulty = 2; break; } - if((_difficulty==2)&& + if((_difficulty==2)&& //if player is hovering over medium and moves joystick up then hover over easy (direction==N)){ _difficulty = 1; break; } - if((_difficulty==2)&& + if((_difficulty==2)&& //if player is hovering over medium and moves joystick down then hover over hard (direction==S)){ _difficulty = 3; break; } - if((_difficulty==3)&& + if((_difficulty==3)&& //if player is hovering over hard and moves joystick up then hover over medium (direction==N)){ _difficulty = 2; break; } - if((_difficulty==3)&& + if((_difficulty==3)&& //if player is hovering over hard and moves joystick down then hover over easy (direction==S)){ _difficulty = 1; break;