submit
Dependencies: mbed Gamepad N5110
Diff: main.cpp
- Revision:
- 16:a52b2441c5ae
- Parent:
- 15:4123abb17291
- Child:
- 18:2ca7bd135b68
--- a/main.cpp Mon Apr 22 09:59:39 2019 +0000 +++ b/main.cpp Tue Apr 23 02:56:04 2019 +0000 @@ -12,6 +12,7 @@ snake snake; Engine engine; finger finger; + ///////////// prototypes /////////////// void init(); void run(); @@ -25,21 +26,21 @@ lcd.init(); while(1){ init(); - pad.tone(1500.0,0.5); + pad.tone(900.0,0.5); engine.welcome(pad,lcd); // show welcome display, waiting for the user to start engine.menu(pad,lcd); // show the select display, waiting for the user to select - // game loop - read input, update the game state and render the display + // choose game and game loop if(engine.game == 0){ while (snake.over == 0) { - run(); // run the game + run(); // run the snake game while (pad.check_event(Gamepad::START_PRESSED) == true){ - engine.pause(pad,lcd); + engine.pause(pad,lcd); // pause the game } wait(engine.p/fps); // and wait for one frame period } over(); // show gameover display, waiting for the user to restart }else if(engine.game == 1){ - finger.run(lcd,pad); + finger.run(lcd,pad); // run the finger-geuss game } } } @@ -61,8 +62,7 @@ // initialies all classes and libraries void init() { - // need to initialise LCD and Gamepad - //lcd.init(); + // need to initialise LCD and Gamepad pad.init(); snake.init(2,3); engine.init(); @@ -70,9 +70,10 @@ lcd.clear(); } +//gameover screen void over() { - int s = snake.get_score(); // get teh scores to show at the gameover display + int s = snake.get_score(); // get the scores to show at the gameover display int hs = snake.hscore; engine.gameover(pad,lcd,s,hs);