Kenthris

Untitled

Apr 29th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. //new variables up in this bitch
  2. int dimensions=10,yes,no,flag=1,max,length,*type,users=0, user, computer,sumi,sumj,obnum,co1,co2,co3,co4,newflag,spot;
  3.  
  4. //once dimensions have been set
  5. obnum = ((dimensions - 1)/2);
  6.  
  7. //after do{}while (counter < players);
  8. if (yes == 0){
  9. do{
  10. newflag=1;//used to confirm that the spot for the first piece of the obstacle is surrounded by at least one more dot
  11. do{
  12. do{
  13. co1 = (rand() % dimensions) + 2;
  14. co2 = (rand() % dimensions) + 3;
  15. }while (array[co1][co2] != '.');
  16. spot = rand() % 4;
  17. if((spot == 0) && (array[co1+1][co2] == '.')){
  18. co3=co1+1;
  19. co4=co2;
  20. newflag=0;
  21. }
  22. else if((spot == 1) && (array[co1-1][co2] == '.')){
  23. co3=co1-1;
  24. co4=co2;
  25. newflag=0;
  26. }
  27. else if((spot == 2) && (array[co1][co2+1] == '.')){
  28. co3=co1;
  29. co4=co2+1;
  30. newflag=0;
  31. }
  32. else if((spot == 3) && (array[co1][co2-1] == '.')){
  33. co3=co1;
  34. co4=co2-1;
  35. newflag=0;
  36. }
  37. }while(newflag!=0);
  38. array[co1][co2] = 'X';//there was a random } here. keep this in mind...
  39. array[co3][co4] = 'X';
  40. obnum--;
  41. }while(obnum > 0);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment