James Heavey
/
EL17JH
FINAL VERSION
Diff: main.cpp
- Revision:
- 10:9f445faa892c
- Parent:
- 9:f6f0f39538c7
- Child:
- 12:f714a9e8c55b
--- a/main.cpp Sun Apr 21 20:44:24 2019 +0000 +++ b/main.cpp Mon Apr 22 11:56:30 2019 +0000 @@ -31,6 +31,8 @@ void update_game(UserInput input); void render(); void welcome(); +void end_screen(); +void main_menu(); ///////////// functions //////////////// int main() @@ -40,54 +42,8 @@ if(number_of_failures > 0) return number_of_failures; #endif - - int fps = 8; // frames per second - bool pause = false; - init(); // initialise and then display welcome screen... - welcome(); // waiting for the user to start - - Bitmap three(three_data, 48, 84); - Bitmap two(two_data, 48, 84); - Bitmap one(one_data, 48, 84); - - lcd.clear(); - three.render(lcd, 0, 0); - lcd.refresh(); - wait(1); - - lcd.clear(); - two.render(lcd, 0, 0); - lcd.refresh(); - wait(1); + main_menu(); - lcd.clear(); - one.render(lcd, 0, 0); - lcd.refresh(); - wait(1); - - render(); // first draw the initial frame - wait(1.0f/fps); // and wait for one frame period - - - // game loop - read input, update the game state and render the display - while (1) { - pong.read_input(pad); - pong.update(pad); - render(); - if (pad.check_event(Gamepad::BACK_PRESSED) == true) { - pause = !pause; - } - while (pause == true) { - lcd.clear(); - lcd.printString(" PAUSED ",0,2); - lcd.refresh(); - if (pad.check_event(Gamepad::BACK_PRESSED) == true) { - pause = !pause; - } - wait(1.0f/fps); - } - wait(1.0f/fps); - } } // initialies all classes and libraries @@ -136,4 +92,82 @@ } -} \ No newline at end of file +} + +void end_screen() { + + while (pad.check_event(Gamepad::START_PRESSED) == false) { + lcd.clear(); + lcd.printString(" RESTART? ",2,2); + lcd.printString(" PRESS START ",1,4); + lcd.refresh(); +// if (pad.check_event(Gamepad::START_PRESSED == true) { +// return true; +// } +// else if (pad.check_event(Gamepad::BACK_PRESSED == true) { +// return false; +// } + + } + main_menu(); +} + +void main_menu() { + int fps = 8; // frames per second + bool pause = false; + init(); // initialise and then display welcome screen... + welcome(); // waiting for the user to start + + Bitmap three(three_data, 48, 84); + Bitmap two(two_data, 48, 84); + Bitmap one(one_data, 48, 84); + + lcd.clear(); + three.render(lcd, 0, 0); + lcd.refresh(); + wait(1); + + lcd.clear(); + two.render(lcd, 0, 0); + lcd.refresh(); + wait(1); + + lcd.clear(); + one.render(lcd, 0, 0); + lcd.refresh(); + wait(1); + + render(); // first draw the initial frame + wait(1.0f/fps); // and wait for one frame period + + + // game loop - read input, update the game state and render the display + while (1) { + pong.read_input(pad); + pong.update(pad); + render(); + if (pad.check_event(Gamepad::BACK_PRESSED) == true) { + pause = !pause; + } + while (pause == true) { + lcd.clear(); + lcd.printString(" PAUSED ",0,2); + lcd.refresh(); + if (pad.check_event(Gamepad::BACK_PRESSED) == true) { + pause = !pause; + } + wait(1.0f/fps); + } + if (pong.get_lives() == 0) { + //if (end_screen() == true) { + // main_menu(); + //} + //else { + // main_menu(); + //} + end_screen(); + } + wait(1.0f/fps); + } +} + \ No newline at end of file