submit

Dependencies:   mbed Gamepad N5110

Revision:
0:b67614a0c4cf
Child:
1:b49c36604125
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 02 06:46:47 2019 +0000
@@ -0,0 +1,77 @@
+///////// pre-processor directives ////////
+#include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+
+/////////////// structs /////////////////
+
+struct UserInput {
+    Direction d;
+    float mag;
+};
+/////////////// objects ///////////////
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+Gamepad pad;
+
+
+///////////// prototypes ///////////////
+void init();
+void update_game(UserInput input);
+void run();
+void welcome();
+
+///////////// functions ////////////////
+int main()
+{
+    int fps = 8;  // frames per second
+    
+    init(); 
+    welcome();  // show welcome display, waiting for the user to start
+    
+    run();  // 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);
+    //    run();
+    //    wait(1.0f/fps);
+   // }
+}
+
+// simple splash screen displayed on start-up
+void welcome() {
+    
+    lcd.printString(" ###SNAKE### ",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);
+    }
+ 
+}
+
+// this function draws each frame on the LCD
+void run()
+{
+    // clear screen, re-draw and refresh
+    lcd.clear();
+   // snake.draw();
+    lcd.refresh();
+}
+
+// initialies all classes and libraries
+void init()
+{
+    // need to initialise LCD and Gamepad 
+    lcd.init();
+    pad.init();
+     
+}
+