ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18jgb

Dependencies:   mbed

Revision:
18:c600a6545e81
Parent:
17:18ae81180853
Child:
19:33c77517cb88
--- a/Spikes/Spikes.cpp	Tue May 19 16:55:43 2020 +0000
+++ b/Spikes/Spikes.cpp	Wed May 20 14:37:02 2020 +0000
@@ -9,6 +9,24 @@
     {0,0,1,0,0},
 };
 
+const int spike2 [5][5] = 
+{
+    {0,0,1,0,0},
+    {0,0,1,1,0},
+    {1,1,1,1,1},
+    {0,0,1,1,0},
+    {0,0,1,0,0},
+};
+
+const int spike3 [5][5] = 
+{
+    {0,0,1,0,0},
+    {0,1,1,0,0},
+    {1,1,1,1,1},
+    {0,1,1,0,0},
+    {0,0,1,0,0},
+};
+
 Spikes::Spikes()
 {
 
@@ -35,6 +53,18 @@
     lcd.drawSprite(_x,_y,5,5,(int*)spike);
 
 }
+void Spikes::draw2(N5110 &lcd)
+{
+    // draw spike 
+    lcd.drawSprite(_x,_y,5,5,(int*)spike2);
+
+}
+void Spikes::draw3(N5110 &lcd)
+{
+    // draw spike 
+    lcd.drawSprite(_x,_y,5,5,(int*)spike3);
+
+}
 
 void Spikes::position(int x)
 {
@@ -48,7 +78,7 @@
     }
     if (x == 3){
         _y = rand() % 19 + 1;
-        _x = 1;
+        _x = 84;
     }
     if (x == 4){
         _y = rand() % 19 + 24;
@@ -66,6 +96,11 @@
     _x = _x + 3;
 }
 
+void Spikes::updatexn()
+{
+    _x = _x - 3;
+}
+
 
 Vector2D Spikes::get_pos() {
     Vector2D p = {_x,_y};