Advertisement
Kenthris

Board Initialization 2 Electric Boogaloo

Apr 28th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. //beginning
  2. int co1, co2;
  3. //these are coordinates to be used in checks later
  4.  
  5. //once dimensions have been chosen
  6. obnum = dimensions - 1;
  7.  
  8. //once the answer to the question "Do you want to populate the board with obstacles?" has been confirmed as yes or no
  9. if (yes == 0){
  10. do{
  11. do{
  12. co1 = (rand() % dimensions) + 2;
  13. co2 = (rand() % dimensions) + 3;
  14. }while (array[co1][co2] != '.');
  15. array[co1][co2] = 'X';
  16. obnum--;
  17. }while(obnum > 0);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement