Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Spikes/Spikes.cpp
- 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};