Lewis Cheadle 201245660

Dependencies:   mbed

Revision:
2:823dea76ff2e
Parent:
1:02f75bf056a0
Child:
3:4494e6928194
--- a/main.cpp	Mon Apr 27 16:52:51 2020 +0000
+++ b/main.cpp	Sat May 16 13:06:29 2020 +0000
@@ -1,27 +1,104 @@
-/* 
-ELEC2645 Embedded Systems Project
-School of Electronic & Electrical Engineering
-University of Leeds
-2019/20
-
-Name: Lewis Cheadle
-Username: ll17lrc
-Student ID Number: 201245660
-Date: 27/03/2020
-*/
-
-// includes
+///////// pre-processor directives ////////
 #include "mbed.h"
 #include "Gamepad.h"
 #include "N5110.h"
+#include "ImpossEngine.h"
+
 
 
-// objects
+/////////////// structs /////////////////
+struct UserInput {
+    Direction d;
+    float mag;
+};
+/////////////// objects ///////////////
+N5110 lcd;
 Gamepad pad;
-N5110 lcd;
+
+///////////// prototypes ///////////////
+void init();
+void update_game(UserInput input);
+void render();
+void welcome();
+void start_menu();
+
+int selector = 1;
+
+int arrow[7][5] = {
+        {0,0,0,0,0},
+        {1,1,0,0,0},
+        {1,1,1,1,0},
+        {1,1,1,1,1},
+        {1,1,1,1,0},
+        {1,1,0,0,0},
+        {0,0,0,0,0},
+};
+    
+
+///////////// functions ////////////////
 
 int main()
 {
-    
+//#ifdef WITH_TESTING
+//    int number_of_failures = run_all_tests();
+//
+//    if(number_of_failures > 0) return number_of_failures;
+//#endif
+
+    int fps = 6;  // frames per second
+
+    init();     // initialise and then display welcome screen...
+    welcome();  // waiting for the user to start
+    start_menu(); // brings up start menu for user to select option
+    ball.init(); //initialise ball position
+    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) {
+        imposs.read_input(pad);
+        imposs.update(pad);
+        render();
+        wait(1.0f/fps);
+    }
 }
 
+
+// this function draws each frame on the LCD
+void render()
+{
+    // clear screen, re-draw and refresh
+    lcd.clear();  
+    imposs.draw(lcd);
+    lcd.refresh();
+}
+
+// simple splash screen displayed on start-up
+void welcome() {
+    
+    lcd.printString("  Welcome to  ",0,1);
+    lcd.printString("  Impossible  ",0,2);  
+    lcd.printString("  Press Start ",0,4);
+    lcd.refresh();
+     
+    // wait flashing LEDs until start button is pressed 
+    while ( pad.start_pressed() == false) {
+        lcd.setContrast( pad.read_pot1());
+        pad.leds_on();
+        wait(0.2);
+        pad.leds_off();
+        wait(0.2);
+    }
+ 
+}
+
+void start_menu() {
+    
+    startmenu.complete(pad);
+    
+    }
+    
+
+
+}
\ No newline at end of file