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.
Fork of fy15raf by
Diff: Asteroids/Asteroid.cpp
- Revision:
- 4:8c6723798227
- Child:
- 5:b230e79d36d6
diff -r 489437d4ebd7 -r 8c6723798227 Asteroids/Asteroid.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Asteroids/Asteroid.cpp Thu Apr 19 16:54:10 2018 +0000
@@ -0,0 +1,39 @@
+#include "Asteroid.h"
+
+Asteroid::Asteroid()
+{
+
+}
+
+Asteroid::~Asteroid()
+{
+
+}
+
+void Asteroid::init(int speed)
+{
+ _size = 5;
+ _x = WIDTH - _size;
+
+ srand(time(NULL));
+ _y1 = rand()%(HEIGHT); // random initial position on y-axis.
+
+ _velocity.x = speed;
+}
+
+void Asteroid::draw(N5110 &lcd)
+{
+
+ int sprite[7][10] = {
+
+ { 0,0,0,0,0,0,0,0,0,0, },
+ { 0,0,0,0,1,1,0,1,0,0, },
+ { 0,0,1,1,0,0,1,0,0,0, },
+ { 0,1,1,1,1,0,1,1,1,0, },
+ { 0,1,1,1,1,0,1,1,1,1, },
+ { 0,0,1,1,0,0,1,0,0,0, },
+ { 0,0,0,0,1,1,0,1,0,0, },
+
+ };
+ lcd.drawSprite(_x,_y1,7,10,(int *)sprite);
+}
\ No newline at end of file
