Kaif Kutchwala 201267448 ELEC2645 Project

Dependencies:   mbed

Revision:
9:e6566d09f087
Parent:
8:5ede90f99a27
Child:
11:59119247dd68
--- a/main.cpp	Sun May 17 17:59:30 2020 +0000
+++ b/main.cpp	Sun May 17 23:00:04 2020 +0000
@@ -59,25 +59,13 @@
 //objects
 Gamepad pad;
 N5110 lcd;
-Ball ball;
-Splash splash;
-Game game;
+Ball ball(lcd);
+Splash splash(lcd, ball);
+Game game(lcd, pad, ball);
 //functions
 void display_menu();
 //variables
-int initial_pos = WIDTH / 2;
-int dir = 1;
-int dirr = 1;
-int aim_line = WIDTH / 2;
-int _user_input_x = 40;
-int _user_input_y = 12;
-int _ball_x = 35;
-int _ball_y = 43;
-int j = 0;
-int k = 0;
-int sizex = 11;
-int sizey = 15;
-char sprite = 'b';
+
 
 int main()
 {
@@ -85,14 +73,15 @@
     lcd.setContrast(0.5);
     pad.init();
     lcd.backLightOn();
-    splash.displayInfo(lcd);
-    splash.playIntro(lcd,ball);
+    //splash.displayInfo(lcd);
+    //splash.playIntro(lcd,ball);
     while (1)
     {
         display_menu();
         if (pad.A_pressed()) {
-            while(!pad.B_pressed()) {
-                game.play(pad, lcd, ball);
+            game.init();
+            while(!pad.X_pressed()) {
+                game.play();
                 wait_ms(100);
                 lcd.refresh();
                 lcd.clear();
@@ -119,49 +108,7 @@
             lcd.turnOff();
             pad.leds(0.0);
         }
-        /*
-        ball.init(lcd);
         
-        float ballx = WIDTH / 2 - 7;
-        float bally = 43;
-
-        lcd.drawLine(0, 24, 84, 24, 1);
-        
-        
-        lcd.printString("Score", 0, 5);
-
-        aim_line += dir;
-        initial_pos += dirr;
-        if (initial_pos > 84)
-        {
-            dirr = -1;
-        }
-
-        if (initial_pos < 0)
-        {
-            dirr = 1;
-        }
-
-        if (aim_line > 84)
-        {
-            dir = -1;
-        }
-
-        if (aim_line < 0)
-        {
-            dir = 1;
-        }
-
-        if (pad.A_pressed())
-        {
-            wait(0.2);
-            ball.set_status(0);
-            ball.playShot(aim_line, 12, lcd);
-
-        }
-        */
-
-        //printf("done");
         wait_ms(100);
         lcd.refresh();
         lcd.clear();
@@ -170,7 +117,7 @@
 
 void display_menu()
 {
-    splash.drawLogo(13, 0, lcd, ball);
+    splash.drawLogo(13, 0);
     lcd.printString("Play", 2, 2);
     lcd.printString("How-To?", 2, 3);
     lcd.printString("Settings", 2, 4);