ELEC2645 (2018/19) / Mbed 2 deprecated el17aio

Dependencies:   mbed

Revision:
43:500b8cff3715
Parent:
31:c7bd3ed16840
Child:
45:fe5fc85a5c73
--- a/Ship/Ship.cpp	Wed May 08 09:22:16 2019 +0000
+++ b/Ship/Ship.cpp	Wed May 08 15:50:40 2019 +0000
@@ -9,7 +9,7 @@
 
 }
 // data needed for first ship: kestrel
-const int kestrel[6][9] =   {
+const int kestrelSprite[6][9] =   {
     { 0,0,0,0,1,0,0,0,0 },
     { 0,0,0,1,1,1,0,0,0 },
     { 0,0,1,1,0,1,1,0,0 },
@@ -17,7 +17,7 @@
     { 1,0,1,1,0,1,1,0,1 },
     { 0,1,1,1,1,1,1,1,0 },
 };
-const int imperion[10][7] = {
+const int imperionSprite[10][7] = {
     {0,1,0,0,0,1,0},
     {0,1,0,0,0,1,0},
     {1,1,0,0,0,1,1},
@@ -29,7 +29,7 @@
     {0,0,1,0,1,0,0},
     {0,0,0,1,0,0,0},
 };
-const int thor[10][7] = {
+const int orionSprite[10][7] = {
     {0,0,0,1,0,0,0},
     {0,0,1,0,1,0,0},
     {0,1,0,0,0,1,0},
@@ -59,17 +59,19 @@
 //    _ship_shape[_ship_height][_ship_width] = ship_shape;
 }
 // Draw the ship ***Note: figure out how to change ship type e.g from kestrel to devotion
-void Ship::draw_ship(N5110 &lcd, int shipno)
+void Ship::draw_ship(N5110 &lcd, SHIP shipUsed)
 {
-    if(shipno == 0) {
-        lcd.drawSprite(_ship_xpos,_ship_ypos,6,9,(int *)kestrel);
-    }
-    if(shipno == 1) {
-        lcd.drawSprite(_ship_xpos,_ship_ypos,10,7,(int *)imperion);
-    }
-    if(shipno == 2) {
-        lcd.drawSprite(_ship_xpos,_ship_ypos,10,7,(int *)thor);
-    }
+        switch (shipUsed) {
+        case kestrel:
+            lcd.drawSprite(_ship_xpos,_ship_ypos,6,9,(int *)kestrelSprite);
+            break;
+        case imperion:
+            lcd.drawSprite(_ship_xpos,_ship_ypos,10,7,(int *)imperionSprite);
+            break;
+        case orion:
+            lcd.drawSprite(_ship_xpos,_ship_ypos,10,7,(int *)orionSprite);
+            break;
+       }
 }
 
 void Ship::update_ship(float x_joystick,float y_joystick)