ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19tb

Dependencies:   mbed

Revision:
15:b15bf9357cd9
Parent:
14:6fe667ec957e
Child:
16:8a65cccd9685
--- a/GraphicEngine/GraphicEngine.cpp	Wed May 13 17:17:57 2020 +0000
+++ b/GraphicEngine/GraphicEngine.cpp	Wed May 13 22:05:17 2020 +0000
@@ -37,12 +37,27 @@
     lcd.drawRect(chick->x, chick->y, chick->width, chick->width, FILL_BLACK);
 }
 
+// this is just going to be white blocks
+// road == '.'
+void GraphhicEngine::drawRoads(int row)
+{
+    // draw across the screen width
+    for(int a = 0; a < 22; a++){
+        showEachRoad(a, row); // x pos is the value of a  
+    }
+}
+
+void GraphicEngine::showEachRoad(int x, int row)
+{
+    lcd.drawSprite(x, 48 - 4*row,4, 4, (int *)road); 
+}
+
 void GraphicEngine::showCar(Car *car){        
     // safety lane
     lcd.drawRect(0, 48 - 4, 84, 4, FILL_TRANSPARENT);
     lcd.drawRect(0, 48 - 4*6, 84, 4, FILL_TRANSPARENT);
         
-    // draw to screen
+    // draw to screen0
     // create an enum to determine the vehicle type
     for(int y = 0; y < 4; y++){
         showIndividualCar(&car[y]);
@@ -82,14 +97,6 @@
     }
 }
 
-// this is just going to be white blocks
-// road == '.'
-void GraphhicEngine::drawRoads(char obj, int x, int y, int width, int height)
-{
-    if(obj == '.'){
-        lcd.drawRect(x, y, width, height, FILL_WHITE);
-    }
-}
 
 // water = ','
 void GraphicEngine::drawWater(char water, int x, int y, int row, in col)
@@ -97,15 +104,22 @@
     int rand_water = 0;
     rand_water = (rand() % 3) + 1;
     
-    // for design purposes the water will have differnet designs
+    // for design purposes the water will have different sprites
     switch(rand_water)
     {
-        case 0:
-            lcd.drawSprite  
-    
+        case 1:
+            lcd.drawSprite(x, y, rows, cols, (int *)first_water);
+            
+        case 2: 
+            lcd.drawSprite(x, y, rows, cols, (int *)second_water);
+            
+        case 3:
+            lcd.drawSprite(x, y, rows, cols, (int *)third_water);
+    }
 }
 
-void GraphicEngine::displayCar(DrawCar &size){
+void GraphicEngine::displayCar(DrawCar &size)
+{
      lcd.drawRect(size.x, size.y, size.width, size.height, FILL_TRANSPARENT);                                                         
 }