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: shot/shot.cpp
- Revision:
- 9:62d6559f0d50
- Parent:
- 8:8287d2ef965d
- Child:
- 10:02ab3324be6c
--- a/shot/shot.cpp Wed Apr 29 15:20:34 2020 +0000 +++ b/shot/shot.cpp Sat May 09 08:27:07 2020 +0000 @@ -36,29 +36,29 @@ int num_pos = rand() % 6;//randomise initial position if (num_pos == 0) { - (*i).x = 0; - (*i).y = HEIGHT/4; - }//left + (*i).x = WIDTH/4; + (*i).y = 0; + }//top if (num_pos == 1) { - (*i).x = 0; - (*i).y = HEIGHT/2; - }//left + (*i).x = WIDTH/2; + (*i).y = 0; + }//top if (num_pos == 2) { - (*i).x = 0; - (*i).y = 3*HEIGHT/4; - }//left + (*i).x = 3*WIDTH/4; + (*i).y = 0; + }//top if (num_pos == 3) { - (*i).x = WIDTH-3; - (*i).y = HEIGHT/4; - }//right + (*i).x = WIDTH/4; + (*i).y = HEIGHT-3; + }//bottom if (num_pos == 4) { - (*i).x = WIDTH-3; - (*i).y = HEIGHT/2; - }//right + (*i).x = WIDTH/2; + (*i).y = HEIGHT-3; + }//bottom if (num_pos == 5) { - (*i).x = WIDTH-3; - (*i).y = 3*HEIGHT/4; - }//right + (*i).x = 3*WIDTH/4; + (*i).y = HEIGHT-3; + }//bottom } @@ -81,8 +81,8 @@ (*i).x +=1; (*i).y +=1;//SE } else if ((*i).dir == 1) { - (*i).x +=1; - (*i).y +=0;//E + (*i).x +=0; + (*i).y +=1;//S } else if ((*i).dir == 2) { (*i).x +=1; (*i).y -=1;//NE @@ -90,8 +90,8 @@ (*i).x -=1; (*i).y -=1;//NW } else if ((*i).dir == 4) { - (*i).x -=1; - (*i).y -=0;//W + (*i).x -=0; + (*i).y -=1;//N } else if ((*i).dir == 5) { (*i).x -=1; (*i).y +=1;//SW @@ -114,7 +114,8 @@ // if beyoud border, delete it and generate new one, keep total number constant if(((*i).x < 0)||((*i).x > WIDTH)||((*i).y < 0)||((*i).y > HEIGHT)|| //keep shots away from starting point - (((*i).x==33)&&((*i).y==3))||(((*i).x==48)&&((*i).y==3))||(((*i).x==33)&&((*i).y==45))||(((*i).x==48)&&((*i).y==45))) + (((*i).x==3)&&((*i).y==27)) || (((*i).x==3)&&((*i).y==18))|| + (((*i).x==80)&&((*i).y==17)) || (((*i).x==80)&&((*i).y==28))) { init_pos(i); (*i).type = ((*i).type + 2)%4;