Kostadin Chakarov / Mbed 2 deprecated el17kec

Dependencies:   mbed

Revision:
12:b3ec47d606a5
Parent:
10:da5743dfb137
--- a/main.cpp	Thu May 09 11:24:12 2019 +0000
+++ b/main.cpp	Thu May 09 11:41:58 2019 +0000
@@ -6,7 +6,7 @@
 Student ID Number:201171978 Date:11/03/2019
 */
 
-/** Breakout logo sprite */
+// Breakout logo sprite 
 const int breakout[10][75] =   {
     { 1,0,0,1,1,0,0,0,0,0,1,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0 },
     { 1,0,1,0,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1 },
@@ -33,21 +33,21 @@
 #include "tests.h"
 #endif
 
-const int fps = 20; /** Sets the fps of the game, doesn't change */
+const int fps = 20; // Sets the fps of the game, doesn't change 
 
 /////////////// objects ///////////////
-AnalogIn pot(PTB2); /** Potentiometer to set contrast of screen */
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);  /** K64F - pwr from 3V3 */
-Gamepad pad; /** Gamepad buttons */
-Paddle paddle; /** Paddle object */
-Ball ball; /** Ball object */
-Map map; /** Map object */
+AnalogIn pot(PTB2); // Potentiometer to set contrast of screen 
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);  // K64F - pwr from 3V3
+Gamepad pad; // Gamepad buttons 
+Paddle paddle; // Paddle object 
+Ball ball; // Ball object 
+Map map; // Map object 
 
 ///////////// function prototypes ///////////////
-void init();        /** Initialize LCD and Gamepad */ 
-void welcome();     /** Simple welcome screen displayed on start-up */ 
-void render();      /** Used as the game loop */ 
-void contrast();    /** Allows to set contrast, if not suitable */ 
+void init();        // Initialize LCD and Gamepad 
+void welcome();     // Simple welcome screen displayed on start-up 
+void render();      // Used as the game loop
+void contrast();    // Allows to set contrast, if not suitable  
 
 ///////////// functions ////////////////
 int main() 
@@ -57,19 +57,19 @@
 if(number_of_failures > 0) return number_of_failures;  
 #endif
  
-    init();     /** Initialize LCD and Gamepad */ 
-    welcome();  /** Waiting for the user to start */ 
-    render();   /** Game Loop */ 
+    init();     // Initialize LCD and Gamepad 
+    welcome();  // Waiting for the user to start  
+    render();   // Game Loop  
 }
 
 
 void init() 
 {
-  lcd.init();               /** Initialize the LCD */
-  pad.init();               /** Initialize the Gamepad */
-  lcd.setContrast(0.55);    /** Initially set contrast to 55% */
-  lcd.normalMode();         /** Normal color mode */
-  lcd.setBrightness(0.5);   /** Puts LED backlight on 50% */
+  lcd.init();               // Initialize the LCD 
+  pad.init();               // Initialize the Gamepad 
+  lcd.setContrast(0.55);    // Initially set contrast to 55% 
+  lcd.normalMode();         // Normal color mode 
+  lcd.setBrightness(0.5);   // Puts LED backlight on 50% 
 }   
 
 /** Simple welcome screen displayed on start-up */
@@ -81,7 +81,7 @@
     lcd.printString("for Controls ",11,5);
     lcd.refresh();   
     
-    /** Wait to move to next menu */
+    // Wait to move to next menu 
     while (pad.check_event(Gamepad::A_PRESSED) == false) 
     {
 
@@ -94,7 +94,7 @@
     lcd.printString("Press Start ",9,4);
     lcd.printString("to begin ",16,5);
     lcd.refresh();  
-    /** Flash LEDs until start button is pressed */
+    // Flash LEDs until start button is pressed 
     while (pad.check_event(Gamepad::START_PRESSED) == false) 
     {
         for (int i = 1; i < 7; i++) 
@@ -109,22 +109,22 @@
 /** Resets everything if game is won / lost */
 void resetGame()
 {
-    paddle.reset(); /** Reset paddle */
-    ball.reset();   /** Reset ball */
-    map.reset();    /** Reset map */
-    map.score = 0;  /** Reset score */
+    paddle.reset(); // Reset paddle
+    ball.reset();   // Reset ball 
+    map.reset();    // Reset map 
+    map.score = 0;  // Reset score 
 }
 
 /** Checks if game is lost */
 void checkLost()
 {
     const Vector2D& posPad = paddle.getPos();
-    /** Checks if ball is below paddle, i.e. lost */
+    // Checks if ball is below paddle, i.e. lost 
     if (ball.getPos().y > posPad.y) 
     {
         while (1) 
         {
-            /** Prints a simple 'lost' message and score and asks if you want to restart */
+            // Prints a simple 'lost' message and score and asks if you want to restart
             lcd.clear();
             char finalscore[14];
             sprintf(finalscore,"Score = %d",map.score);
@@ -134,7 +134,7 @@
             lcd.printString("to restart",12,4);
             wait(0.1);
             lcd.refresh();
-            /** Checks if reset button is pressed, if it is reset */
+            // Checks if reset button is pressed, if it is reset 
             if (pad.check_event(Gamepad::A_PRESSED) == true)
             {
                 resetGame();
@@ -148,15 +148,15 @@
 void checkWon() 
 {
     if (map.checkLevel()) {
-        /** We have cleared a level */
-        ball.reset();       /** Reset ball */
-        paddle.reset();     /** Reset paddle */
+        // We have cleared a level 
+        ball.reset();       // Reset ball 
+        paddle.reset();     // Reset paddle 
         
         if (map.hasWon()) {
-             /** We have cleared all levels */
+             // We have cleared all levels 
              while (1) 
             {   
-                /** Prints win message and score and asks if you want to restart */
+                // Prints win message and score and asks if you want to restart 
                 lcd.clear();
                 char finalscore[14];
                 sprintf(finalscore,"Score = %d",map.score);
@@ -166,7 +166,7 @@
                 lcd.printString("to restart",12,4);
                 wait(0.1);
                 lcd.refresh();
-                /** Checks if reset button is pressed, if it is reset */
+                // Checks if reset button is pressed, if it is reset 
                 if (pad.check_event(Gamepad::B_PRESSED) == true)
                 {
                     resetGame();
@@ -182,16 +182,16 @@
 {
     
     
-    map.initBricks(); /** Initialize the map */
+    map.initBricks(); // Initialize the map 
     
     while(1) 
     {  
         
-        /** Physics, movement, control input + game logic */
-        /** Control Input */
+        // Physics, movement, control input + game logic 
+        // Control Input 
         paddle.controlPaddle(pad); 
         
-        /** Movement and physics */
+        // Movement and physics 
         ball.move();
         paddle.move();
         
@@ -199,18 +199,18 @@
         map.update();
         ball.hitPad(paddle);
         
-        /** Rendering */
-        lcd.clear();        /** Initialize render */
-        contrast();         /** Sets contrast */
-        map.drawMap(lcd);   /** Draw map objects */
-        paddle.draw(lcd);   /** Draws paddle */
-        ball.draw(lcd);     /** Draws ball */
+        // Rendering 
+        lcd.clear();        // Initialize render 
+        contrast();         // Sets contrast 
+        map.drawMap(lcd);   // Draw map objects 
+        paddle.draw(lcd);   // Draws paddle 
+        ball.draw(lcd);     // Draws ball 
         
-        lcd.refresh();      /** Finalize render */
+        lcd.refresh();      // Finalize render 
         
-        wait(1.0f/fps);     /** Frames per second */
+        wait(1.0f/fps);     // Frames per second 
         
-        /** Check Lost/Won */
+        // Check Lost/Won 
         checkLost();
         checkWon();
     }
@@ -219,7 +219,7 @@
 /** Allows to set contrast, if not suitable */
 void contrast() 
 {
-    float contrast = pot.read(); /** Read value from potentiometer(0-1) */
-    lcd.setContrast(contrast); /** Set that value for the contrast */
+    float contrast = pot.read(); // Read value from potentiometer(0-1) 
+    lcd.setContrast(contrast); // Set that value for the contrast 
 }
     
\ No newline at end of file