ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_ll17lrc_v2

Dependencies:   mbed

Revision:
13:fd290d2fd917
Parent:
12:299479b6bb59
--- a/Five/Five.cpp	Tue May 26 18:16:31 2020 +0000
+++ b/Five/Five.cpp	Tue May 26 22:41:23 2020 +0000
@@ -10,13 +10,15 @@
 
 }
 
-int one;
-int two;
-int three;
-int four;
-int five;
-int six;
+//Initialising counters for the objects in the map
+int object_one;
+int object_two;
+int object_three;
+int object_four;
+int object_five;
+int object_six;
 
+//Sprite that stores the path layout of the map
 int level_five[48][84] {
     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
@@ -68,62 +70,65 @@
     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
 };
 
+//Draws the sprite containing the path and all of the objects and obstacles
+//on the map using seperate counters for seperate objects that were initialised
+//above
 void Five::draw(N5110 &lcd)
 {
     lcd.drawSprite(0,0,48,84,(int *)level_five);
     
-    if(one < 15){
-        lcd.drawRect(one + 18,11,2,7,FILL_BLACK);
-        one++;
+    if(object_one < 15){
+        lcd.drawRect(object_one + 18,11,2,7,FILL_BLACK);
+        object_one++;
         }
-    if(one == 15){
-        one = 0;
+    if(object_one == 15){
+        object_one = 0;
         }
         
-    if(two < 12){
-        two++;
+    if(object_two < 12){
+        object_two++;
         lcd.drawRect(33,27,5,7,FILL_BLACK);
         }
-    if(12 <= two < 24){
-        two++;
+    if(12 <= object_two < 24){
+        object_two++;
         }
-    if(two == 24){
-        two = 0;
+    if(object_two == 24){
+        object_two = 0;
         }
         
-    if(three < 19){
-        three++;
-        lcd.drawRect(48,19-three,6,2,FILL_BLACK);
+    if(object_three < 19){
+        object_three++;
+        lcd.drawRect(48,19-object_three,6,2,FILL_BLACK);
         }
-    if(three == 19){
-        three = 0;
+    if(object_three == 19){
+        object_three = 0;
         }
         
-    if(four < 12){
-        four++;
+    if(object_four < 12){
+        object_four++;
         lcd.drawRect(58,2,4,12,FILL_BLACK);
         }
-    if(12 <= four < 36){
-        four++;
+    if(12 <= object_four < 36){
+        object_four++;
         }
-    if(four == 36){
-        four = 0;
+    if(object_four == 36){
+        object_four = 0;
         }
     
-    if(five < 12){
-        lcd.drawCircle(52,45,five,FILL_TRANSPARENT);
-        five++;
+    if(object_five < 12){
+        lcd.drawCircle(52,45,object_five,FILL_TRANSPARENT);
+        object_five++;
         }
-    if(five == 12){
-        five = 0;
+    if(object_five == 12){
+        object_five = 0;
         }
         
-    if(six < 6){
-        lcd.drawCircle(65,30,six,FILL_TRANSPARENT);
-        six++;
+    if(object_six < 6){
+        lcd.drawCircle(65,30,object_six,FILL_TRANSPARENT);
+        object_six++;
         }
-    if(six == 6){
-        six = 0;
+    if(object_six == 6){
+        object_six = 0;
         }
     
 }
\ No newline at end of file