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: Asteroids/Asteroid.cpp
- Revision:
- 5:b230e79d36d6
- Parent:
- 4:8c6723798227
- Child:
- 6:7b733b2a6cf6
--- a/Asteroids/Asteroid.cpp Thu Apr 19 16:54:10 2018 +0000
+++ b/Asteroids/Asteroid.cpp Thu Apr 19 17:46:28 2018 +0000
@@ -36,4 +36,14 @@
};
lcd.drawSprite(_x,_y1,7,10,(int *)sprite);
+}
+
+void Asteroid::update()
+{
+ if(_x>0) {
+ _x -= _velocity.x;
+ } else {
+ _x = WIDTH - _size; //start from the begining again
+ _y1= rand()%(HEIGHT);
+ }
}
\ No newline at end of file