Advertisement
Guest User

Untitled

a guest
Jan 9th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int mapHeight;
  6. int mapWidth;
  7. int mapDim;
  8. int bossLocation;
  9.  
  10.  
  11. void bossRoomGen(){
  12. bossLocation = rand()% (mapDim*mapDim);
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18.  
  19. int mapArray[mapDim*mapDim];
  20. int i;
  21.  
  22. srand(time(NULL));
  23.  
  24. printf("Enter your desired map size:\n");//Only works for 3 or 2 for some reason
  25. scanf(" %d", &mapDim);
  26.  
  27. bossRoomGen();
  28.  
  29. for(i = 0; i<(mapDim*mapDim); i++){
  30. if(bossLocation == i){
  31. mapArray[i] = 3;
  32. i++;
  33. }
  34.  
  35. mapArray[i] = rand()%2 + 1;
  36. }
  37.  
  38. for(i = 0; i< mapDim; i++){
  39. int x;
  40. for(x = 0; x<mapDim; x++){
  41. int currentVal = mapArray[(mapDim*(i+1)) - (mapDim - x)];
  42. printf(" %d\t", currentVal);
  43. }
  44. printf("\n");
  45. }
  46.  
  47.  
  48.  
  49.  
  50. return 0;
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement