Ellis Blackford Stroud 201155309

Dependencies:   mbed FATFileSystem

Revision:
3:a8960004d261
Parent:
2:81cfa8310f55
Child:
4:035448357749
--- a/main.cpp	Wed Mar 20 18:23:22 2019 +0000
+++ b/main.cpp	Fri Mar 29 18:45:40 2019 +0000
@@ -11,12 +11,14 @@
 #include "Gamepad.h"
 #include "N5110.h"
 #include "Menu.h"
+#include "Ball.h"
+
 
 // objects 
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad pad;
 Menu menu;
-
+Ball ball;
 void init();
 
 int main()
@@ -24,24 +26,41 @@
     init();
     lcd.clear();
     menu.print_welcome(lcd);
-    lcd.refresh();
-    wait(3);
     menu.print_menu(lcd);
-    lcd.refresh();
+    bool start_game = false; 
+    
+    //menu loop navigates menu until game started
+    while(start_game == false) {
+        menu.menu_select(pad, lcd); //main menu cursor code loops until start pressed
+        start_game = menu.menu_change(lcd, pad); //changes menu screen to choice returns true if game started
+        //check if game has been started
+        if(start_game == false) {
+            menu.menu_return(lcd, pad); //if game not started wait until back pressed
+        }
+    }  
+    //code to run game 
     
-    //cursor begins on start 
-    MenuChoices m = START;
+    int x_pos = 24;
+    int y_pos = 24;
+    float x_vel = 0.0f;
+    float y_vel = 0.0f;
+    ball.init(x_pos, y_pos);
+    ball.set_vel(x_vel, y_vel);
+    
+    while(1){ 
+    
+        lcd.clear();
+        ball.move_ball();
+        ball.draw_ball(lcd);
+        ball.read_joy(pad);
+        ball.draw_aim(lcd);
+        ball.draw_screen(lcd);
+        ball.shoot_ball(pad);
+        lcd.refresh();
 
-    while(1) {
-
-        m = menu.menu_choice(m, pad, lcd);
-        int d = pad.get_direction();
-
-        printf("menu choice = %i direction = %i \n" , m, d);
-        lcd.refresh();
         wait(0.1);
-        
     }
+    
 }
 
 void init()