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:
- 4:55a0509c4874
- Parent:
- 3:bd3465a70a5a
- Child:
- 5:915bcac4e9b9
--- a/Ball/Ball.cpp Mon Apr 15 13:40:49 2019 +0000 +++ b/Ball/Ball.cpp Tue Apr 16 09:48:37 2019 +0000 @@ -1,5 +1,6 @@ #include "Ball.h" + Ball::Ball() { @@ -37,7 +38,7 @@ } void Ball::start(N5110 &lcd){ - if (_y!=28){ + if (_y!=36){ _y+=1; } } @@ -81,21 +82,46 @@ _d = pad.get_direction(); } void Ball::set_field(N5110 &lcd){ - + lcd.drawLine(40,11,40,14,1); + lcd.drawLine(42,11,42,14,1); + lcd.drawLine(44,11,44,14,1); + lcd.drawLine(40,14,44,14,2); + /* lcd.drawCircle(25,2,2,FILL_BLACK); //NE lcd.drawCircle(65,2,2,FILL_BLACK); //NW lcd.drawCircle(65,40,2,FILL_BLACK); //SE lcd.drawCircle(25,40,2,FILL_BLACK); //SW lcd.drawCircle(3,20,2,FILL_BLACK); //E - lcd.drawCircle(80,20,2,FILL_BLACK); - - /* - for(int i=0;i<5;i++){ - get_direction(); - while (_d==N||_d==S){ - get_direction(); + lcd.drawCircle(80,20,2,FILL_BLACK); + */ + int d=0; + for(int i=0;i<3;i++){ + srand(time(NULL)); + d = rand() % 10; + printf("Direction %i \n",d); + //while (d==N||d==S){ + //get_direction(pad); + //} + if (d==1){ //NE + field[i].x=25; + field[i].y=2; + field[i].position=1; } - if (d==NE){ - lcd.drawCircle(42,4,2,FILL_BLACK); - */ -} \ No newline at end of file + if (d==2){ //NW + field[i].x=65; + field[i].y=2; + field[i].position=1; + } + if (d==3){ //SW + field[i].x=25; + field[i].y=40; + 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); + lcd.drawCircle(field[2].x,field[2].y,2,FILL_BLACK); + lcd.drawCircle(field[3].x,field[3].y,2,FILL_BLACK); + +}