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: Ball/Ball.cpp
- Revision:
- 5:915bcac4e9b9
- Parent:
- 4:55a0509c4874
- Child:
- 6:3e50f2cf4366
--- a/Ball/Ball.cpp Tue Apr 16 09:48:37 2019 +0000 +++ b/Ball/Ball.cpp Tue Apr 16 10:17:21 2019 +0000 @@ -95,10 +95,10 @@ lcd.drawCircle(80,20,2,FILL_BLACK); */ int d=0; + srand(time(NULL)); for(int i=0;i<3;i++){ - srand(time(NULL)); - d = rand() % 10; - printf("Direction %i \n",d); + d = 1+ rand() % 6; + //printf("Direction %i \n",d); //while (d==N||d==S){ //get_direction(pad); //} @@ -117,7 +117,21 @@ field[i].y=40; field[i].position=1; } - + if (d==4){ //SE + field[i].x=65; + field[i].y=40; + field[i].position=1; + } + if (d==5){ //E + field[i].x=3; + field[i].y=20; + field[i].position=1; + } + if (d==3){ //W + field[i].x=80; + field[i].y=20; + field[i].position=1; + } } lcd.drawCircle(field[0].x,field[0].y,2,FILL_BLACK); lcd.drawCircle(field[1].x,field[1].y,2,FILL_BLACK);