ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el19tb

Dependencies:   mbed

Revision:
17:67dbdfcdcec2
Parent:
16:8a65cccd9685
Child:
18:6be4c3c94a3d
--- a/GraphicEngine/GraphicEngine.cpp	Wed May 13 23:07:05 2020 +0000
+++ b/GraphicEngine/GraphicEngine.cpp	Thu May 14 01:07:27 2020 +0000
@@ -85,6 +85,44 @@
     displayCar(temp_car);
 }
 
+void GraphicEngine::showWater(Water *water)
+{
+    for(int i = 0; i < 22; i++)
+    {
+        showIndividualWater(&water[i]);    
+    }
+}
+
+void GraphicEngine::showIndividualWater(Water *water)
+{
+    // POTENTIAL BUG, add break later
+    switch(water->sprite){
+        case 'F':
+            displayFirstWater(water);
+        case 'S':
+            displaySecondWater(water);
+        case 'T':
+            displayThirdWater(water);
+    }   
+}
+
+// x is the offset in the for loop, y is the row number
+void GraphicEngine::displayFirstWater(Water &waterobj)
+{
+    lcd.drawSprite(waterobj.x,48 - 4*waterobj.y, 4, 4, (int *)first_water);   
+}
+
+// x is the offset in the for loop, y is the row number
+void GraphicEngine::displaySecondWater(Water &waterobj)
+{
+    lcd.drawSprite(waterobj.x,48 - 4*waterobj.y, 4, 4, (int *)second_water);   
+}
+
+// x is the offset in the for loop, y is the row number
+void GraphicEngine::displayThirdWater(Water &waterobj)
+{
+    lcd.drawSprite(waterobj.x,48 - 4*waterobj.y, 4, 4, (int *)third_water);   
+}
 
 void GraphicEngine::drawVehicleSprites(char obj, int x, int y, int rows, int cols)
 {