Ellis Blackford Stroud 201155309

Dependencies:   mbed FATFileSystem

Revision:
5:0b31909caf7f
Parent:
4:035448357749
Child:
8:d410856c6d04
--- a/main.cpp	Mon Apr 08 15:10:28 2019 +0000
+++ b/main.cpp	Wed Apr 17 10:27:09 2019 +0000
@@ -7,19 +7,20 @@
 Student ID Number: 201155309
 Date: 09/05/19
 */
+
 #include "mbed.h"
 #include "Gamepad.h"
 #include "N5110.h"
 #include "Menu.h"
-#include "Ball.h"
-
+#include "GolfEngine.h"
 
 // objects 
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
 Gamepad pad;
 Menu menu;
-Ball ball;
+GolfEngine golf;
 void init();
+
 int frame_rate = 40;
 
 int main()
@@ -27,30 +28,24 @@
     init();
     lcd.clear();
     menu.print_welcome(lcd);
-    menu.print_menu(lcd); 
+    lcd.clear();
     bool start_game = false; 
     
-    while(start_game== false) {   //menu loop navigates menu until game started
-
-        lcd.refresh();
-        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        
+    while(start_game == false) {   //menu loop navigates menu until game started
+        
+        menu.menu_screen(pad, lcd); 
+        start_game = menu.menu_change(lcd, pad); //changes menu screen to selected screen the returns true when start game 
     }  
     
-    frame_rate = menu.get_frame_rate(); 
+    frame_rate = menu.get_frame_rate(); //can be changed in the settings screen
     
     //game loop to run game
     
-    int x_pos = 24;
-    int y_pos = 24;
-    ball.init(x_pos, y_pos);
-    
     while(1){ 
     
         lcd.clear();    
-        ball.shoot_ball(pad);
-        ball.move_ball(frame_rate, lcd);
-        ball.draw_screen(lcd, pad);
+        golf.update_ball(pad, frame_rate);
+        golf.drawGame(lcd);        
         lcd.refresh();
 
         wait(1.0f/frame_rate); //time between loops/frames
@@ -64,5 +59,6 @@
     lcd.init();
     pad.init();
     menu.init();
+    golf.init();
     lcd.setContrast(0.5f);
 }