Simple fish eat program
Dependencies: mbed mbed-rtos N5110 ShiftReg Tone
Diff: classes/FishEngine.cpp
- Revision:
- 8:fe51fbf81dee
- Parent:
- 6:7aafcaf7cbe2
- Child:
- 10:e221bd1ce3ec
diff -r 6f951d175df6 -r fe51fbf81dee classes/FishEngine.cpp --- a/classes/FishEngine.cpp Thu Mar 25 13:00:19 2021 +0000 +++ b/classes/FishEngine.cpp Mon Mar 29 20:32:45 2021 +0000 @@ -29,6 +29,35 @@ lcd.refresh(); } +void FishEngine::Instructions(N5110 &lcd){ + do{ + lcd.clear(); + lcd.printString(" -- Welcome --",0,0); + lcd.printString("Use the",0,2); + lcd.printString("joystick to ",0,3); + lcd.printString("move the fish",0,4); + lcd.refresh(); + + wait_ms(2000); + + lcd.clear(); + lcd.printString("remeber to",0,1); + lcd.printString("only eat fish",0,2); + lcd.printString("smaller than",0,3); + lcd.printString("you!!",0,4); + lcd.refresh(); + + wait_ms(2000); + + lcd.clear(); + lcd.printString("Hold B to Exit",0,2); + lcd.refresh(); + + wait_ms(2000); + + }while(settings.buttonB_state(ButtonB) == false); +} + // creates the games main menu screen with scrolling ability through the use of a // state machine. void FishEngine::mainMenu(N5110 &lcd, Tone &dac, Joystick &joystick){ @@ -86,7 +115,6 @@ //case for new game case 0: if(settings.buttonA_state(ButtonA)){ - gamePlay(lcd,dac); } switch(direction) { case UP: @@ -104,7 +132,6 @@ //case for HighScore case 1: if(settings.buttonA_state(ButtonA)){ - highScore(lcd); } switch(direction) { case UP: @@ -122,6 +149,7 @@ //case for how to play case 2: if(settings.buttonA_state(ButtonA)){ + graphics.screenFlash(lcd); Instructions(lcd); } switch(direction) { @@ -166,43 +194,4 @@ lcd.refresh(); wait_ms(500); } -} - -// function for game play -void FishEngine::gamePlay(N5110 &lcd, Tone &dac){ - graphics.screenFlash(lcd); - - do{ - lcd.clear(); - lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); //draws screen border - lcd.printString(" Play game", 10, 2); - lcd.refresh(); - wait_ms(1000/10); - }while(settings.buttonB_state(ButtonA) == false); -} - -//function for viewing high score -void FishEngine::highScore(N5110 &lcd){ - graphics.screenFlash(lcd); - - do{ - lcd.clear(); - lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); //draws screen border - lcd.printString(" High score", 10, 2); - lcd.refresh(); - wait_ms(1000/10); - }while(settings.buttonB_state(ButtonB) == false); -} - -//function for providing instruction on how to play -void FishEngine::Instructions(N5110 &lcd){ - graphics.screenFlash(lcd); - - do{ - lcd.clear(); - lcd.drawRect(0,0,84,48,FILL_TRANSPARENT); //draws screen border - lcd.printString(" How to play", 10, 2); - lcd.refresh(); - wait_ms(1000/10); - }while(settings.buttonB_state(ButtonA) == false); -} +} \ No newline at end of file