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:
- 6:7b733b2a6cf6
- Parent:
- 5:b230e79d36d6
- Child:
- 8:13cef7cb872e
--- a/Asteroids/Asteroid.cpp Thu Apr 19 17:46:28 2018 +0000
+++ b/Asteroids/Asteroid.cpp Fri Apr 20 21:03:05 2018 +0000
@@ -15,8 +15,8 @@
_size = 5;
_x = WIDTH - _size;
- srand(time(NULL));
- _y1 = rand()%(HEIGHT); // random initial position on y-axis.
+ // srand(time(NULL));
+ _y1 = 22; //rand()%(HEIGHT); // random initial position on y-axis.
_velocity.x = speed;
}
@@ -24,9 +24,8 @@
void Asteroid::draw(N5110 &lcd)
{
- int sprite[7][10] = {
+ int sprite[6][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, },
@@ -35,7 +34,7 @@
{ 0,0,0,0,1,1,0,1,0,0, },
};
- lcd.drawSprite(_x,_y1,7,10,(int *)sprite);
+ lcd.drawSprite(_x,_y1,6,10,(int *)sprite);
}
void Asteroid::update()
@@ -44,6 +43,12 @@
_x -= _velocity.x;
} else {
_x = WIDTH - _size; //start from the begining again
- _y1= rand()%(HEIGHT);
+ _y1= 22; //rand()%(HEIGHT);
}
+}
+
+Vector2D Asteroid::get_pos()
+{
+ Vector2D p = {_x,_y1};
+ return p;
}
\ No newline at end of file