Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //new variables up in this bitch
- int dimensions=10,yes,no,flag=1,max,length,*type,users=0, user, computer,sumi,sumj,obnum,co1,co2,co3,co4,newflag,spot;
- //once dimensions have been set
- obnum = ((dimensions - 1)/2);
- //after do{}while (counter < players);
- if (yes == 0){
- do{
- newflag=1;//used to confirm that the spot for the first piece of the obstacle is surrounded by at least one more dot
- do{
- do{
- co1 = (rand() % dimensions) + 2;
- co2 = (rand() % dimensions) + 3;
- }while (array[co1][co2] != '.');
- spot = rand() % 4;
- if((spot == 0) && (array[co1+1][co2] == '.')){
- co3=co1+1;
- co4=co2;
- newflag=0;
- }
- else if((spot == 1) && (array[co1-1][co2] == '.')){
- co3=co1-1;
- co4=co2;
- newflag=0;
- }
- else if((spot == 2) && (array[co1][co2+1] == '.')){
- co3=co1;
- co4=co2+1;
- newflag=0;
- }
- else if((spot == 3) && (array[co1][co2-1] == '.')){
- co3=co1;
- co4=co2-1;
- newflag=0;
- }
- }while(newflag!=0);
- array[co1][co2] = 'X';//there was a random } here. keep this in mind...
- array[co3][co4] = 'X';
- obnum--;
- }while(obnum > 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment