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.
main.cpp
- Committer:
- ahmeou
- Date:
- 2020-07-08
- Revision:
- 1:25f13b341b11
- Parent:
- 0:17bdfb0e7069
- Child:
- 2:8f1130b99681
File content as of revision 1:25f13b341b11:
#include "MicroBit.h" #include "Screen.h" #include "Bullet.h" #include "Spacecraft.h" MicroBit ubit; int main(){ Screen screen(&ubit); Spacecraft spacecraft; Bullet bullet; bullet.setX(spacecraft.getX()); bullet.setY(spacecraft.getY()); for(int i = 0; i < 100; i++){ screen.draw(bullet); screen.draw(spacecraft); screen.refresh(); // move spacecraft spacecraft.setX(spacecraft.getX() + 1 - 2 * ubit.random(1)); // move bullet for(int i = 0; i < 2; i++){ if(bullet.getY() == 0) bullet.setX(spacecraft.getX()); bullet.move(); ubit.sleep(200); } } release_fiber(); }