Ahmed Hedait / Mbed 2 deprecated el16ah

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ahmedhedait
Date:
Mon Apr 30 03:21:44 2018 +0000
Parent:
3:8c1d53e31ed7
Child:
5:713ff302791f
Commit message:
I finished with the coding of which the circle should not get outside the drawn borders of the maze.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Apr 30 02:10:21 2018 +0000
+++ b/main.cpp	Mon Apr 30 03:21:44 2018 +0000
@@ -91,6 +91,8 @@
             circx += speed;
         }
 
+
+
         lcd.printString("           scr",0,0);
         lcd.drawRect(0,0,65,48,FILL_TRANSPARENT);
         lcd.setPixel(64,39,false);
@@ -99,11 +101,30 @@
         lcd.setPixel(64,42,false);
         lcd.setPixel(64,43,false);
         lcd.setPixel(64,44,false);
-        
+
         printf("X = %f Y = %f", circx, circy);
         lcd.drawCircle(circx,circy,2,FILL_BLACK);
 
-        wait(1/10);
-        lcd.refresh();
-    }
+        if (circy < 3) {
+            circy = 3;
+        }
+        
+        if (circy > HEIGHT - 4) {
+            circy = HEIGHT - 4;
+        }
+
+        if (circx < 3) {
+            circx = 3;
+        }
+
+
+        if (circx > 61) {
+            circx = 61;
+        }
+
+    
+
+    wait(1/10);
+    lcd.refresh();
+}
 }
\ No newline at end of file