ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19tb

Dependencies:   mbed

Revision:
7:1dce07fd0867
Parent:
6:e285eaf8bdcd
Child:
8:52794de935b2
--- a/CrossyChicken/CrossyChicken.cpp	Mon May 11 21:16:12 2020 +0000
+++ b/CrossyChicken/CrossyChicken.cpp	Mon May 11 22:57:53 2020 +0000
@@ -24,6 +24,10 @@
 Car firstLane[2];
 Car secondLane[2];  
 Car thirdLane[3];
+Car fourthLane[3];
+Car log1Lane[2];
+Car lo[2];
+Car logger[2];
 
 //class that whill show objects
 GraphicEngine graphics(chickenptr);
@@ -38,21 +42,47 @@
     
     //first lane of left racers
     firstLane[0].setSeperation(0);
-    firstLane[1].setSeperation(40);
+    firstLane[1].setSeperation(20);
     firstLane[0].setRow(2);
     firstLane[1].setRow(2);
     
     secondLane[0].setSeperation(0);
-    secondLane[1].setSeperation(30);
+    secondLane[1].setSeperation(20);
     secondLane[0].setRow(3);
     secondLane[1].setRow(3);
     
-    thirdLane[0].setSeperation(30);
-    thirdLane[1].setSeperation(0);
-    thirdLane[2].setSeperation(50);
+    thirdLane[0].setSeperation(0);
+    thirdLane[1].setSeperation(20);
+    thirdLane[2].setSeperation(40);
     thirdLane[0].setRow(4);
     thirdLane[1].setRow(4);
     thirdLane[2].setRow(4);
+    
+    fourthLane[0].setSeperation(10);
+    fourthLane[1].setSeperation(30);
+    fourthLane[2].setSeperation(50);
+    fourthLane[0].setRow(5);
+    fourthLane[1].setRow(5);
+    fourthLane[2].setRow(5);
+    
+    // log lane 1
+    log1Lane[0].setSeperation(0);
+    log1Lane[1].setSeperation(20);
+    log1Lane[0].setRow(7);
+    log1Lane[1].setRow(7);
+    
+    // log lane 2
+    lo[0].setSeperation(10);
+    lo[1].setSeperation(30);
+    lo[0].setRow(8);
+    lo[1].setRow(8);
+    
+    // log lane 3
+    logger[0].setSeperation(0);
+    logger[1].setSeperation(20);
+    logger[0].setRow(9);
+    logger[1].setRow(9);
+
 
     //keep reading and processing user input
     while(1) {
@@ -60,9 +90,8 @@
         graphics.showChicken(); 
         process_input();
         
-        for(int i = 0; i < 2; i++){
+         for(int i = 0; i < 2; i++){
             moveCar(&firstLane[i], 2, (-2)); // change x position (moving)
-            // collision(&firstLane[i]);
         }
         
         for(int x = 0; x < 2; x++){
@@ -71,23 +100,44 @@
         
         for(int t = 0; t < 3; t++){
             moveCar(&thirdLane[t], 2, 1);
-           //collision(&thirdLane[t]);
+        }
+        
+        for(int c = 0; c < 3; c++){
+            moveCar(&fourthLane[c], 2, 1);
+        }
+        
+        for(int v = 0; v < 2; v++){
+            moveCar(&log1Lane[v], 2, 1);
+        }
+       
+        for(int b = 0; b < 2; b++){
+            moveCar(&lo[b], 2, 1);
+            moveCar(&logger[b], 2, 2);
 
         }
         
         graphics.showCar(firstLane);
         graphics.showCar(secondLane);
         graphics.showCar(thirdLane);
-        
+        graphics.showCar(fourthLane);
+        graphics.showCar(log1Lane);
+        graphics.showCar(lo);
+        //graphics.showCar(logger);
+
         for(int t = 0; t < 3; t++){
             collision(&thirdLane[t]);
         }
         
         graphics.refresh();
-        wait_ms(100);
+        wait_ms(50);
     } 
 }
 
+// log intersects then frog.x = log[i].speed
+// frog is attached function
+// detach the frog when user goes up or down
+// if the frog is back to the safe zone detatch also
+// whenever the frog moves detach
 //A moves right
 //X moves upward
 //B moves downward