ZIYI CHEN ml17z4c 201214999
Dependencies: mbed
Diff: main.cpp
- Revision:
- 5:f1a193bb84a2
- Parent:
- 4:104a7dafcecd
- Child:
- 6:13c43182a848
diff -r 104a7dafcecd -r f1a193bb84a2 main.cpp --- a/main.cpp Wed Apr 17 03:37:29 2019 +0000 +++ b/main.cpp Thu Apr 25 03:13:24 2019 +0000 @@ -12,13 +12,66 @@ #include "N5110.h" #include "Snake_menu.h" +#include "Gamepad.h" + -int main() { - Snake_menu(); - } +/////////////// objects /////////////// +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); +Gamepad pad; + + +///////////// prototypes /////////////// +void init(); +//void update_game(UserInput input); +void render(); +void welcome(); + +///////////// functions //////////////// +int main() +{ + + int fps = 8; // frames per second + + init(); // initialise and then display welcome screen... + welcome(); // waiting for the user to start + + render(); // first draw the initial frame + +} + +// initialies all classes and libraries +void init() +{ + //initialise LCD and Gamepad + lcd.init(); + pad.init(); +} + +// this function draws each frame on the LCD +void render() +{ + // clear screen, re-draw and refresh + lcd.clear(); + lcd.refresh(); +} + +// simple splash screen displayed on start-up +void welcome() { - + lcd.printString(" Snake Game! ",0,1); + lcd.printString(" Press Start ",0,4); + lcd.refresh(); + + // wait flashing LEDs until start button is pressed + while ( pad.check_event(Gamepad::START_PRESSED) == false) { + pad.leds_on(); + wait(0.1); + pad.leds_off(); + wait(0.1); + } + +}