Guest User

Untitled

a guest
Jan 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6.  
  7. class Blocks {
  8. public:
  9. int x;
  10. int y;
  11. void Sand();
  12. void Status();
  13. private:
  14. int w,z;
  15.  
  16. };
  17.  
  18. char world[15][15] =
  19. {
  20. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  21. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  22. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  23. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  24. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  25. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  26. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  27. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  28. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  29. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  30. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  31. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  32. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  33. {'W','W','W','W','W','W','W','W','W','W','W','W','W','W','W'},
  34. {'W','W','W','W','W','W','W','W','W','W ','W','W','W','W','W'}
  35. };
  36. void drawWorld();
  37. void Blocks::Sand()
  38. {
  39.  
  40. w = x;
  41. z = y;
  42.  
  43. if (world[z+1][w] == ' ')
  44. {
  45.  
  46. while(world[z+1][w] == ' ')
  47. z++;
  48. world[z][w] = 'S';
  49. drawWorld();
  50.  
  51. //z++;
  52.  
  53. }
  54. else
  55. cout << "no room for sand" << endl;
  56.  
  57. }
  58. void Blocks::Status()
  59. {
  60. Blocks::Sand();
  61. }
  62.  
  63. void drawWorld()
  64. {
  65. Blocks pos;
  66. for(pos.y = 0; pos.y < 15; pos.y++) // build world
  67. {
  68. cout << endl;
  69. for (pos.x = 0; pos.x < 15; pos.x++)
  70. {
  71. cout << world[pos.y][pos.x];
  72. }
  73. }
  74. }
  75.  
  76. int main()
  77. {
  78. Blocks pos;
  79. char i=1;
  80. int dirt=0; // joe
  81. int health=100;
  82. world[0][0]=' '; // sets spawn
  83. pos.x = 0;
  84. pos.y = 0;
  85.  
  86. do
  87. {
  88. cout << endl << endl << endl;
  89.  
  90. cout << "===============" << endl;
  91. cout << "Dirt Blocks: " << dirt << endl;
  92. drawWorld(); // create world
  93. cout << endl << world[pos.y][pos.x];
  94. cout << endl;
  95.  
  96. cin >> i;
  97.  
  98. switch(i)
  99. {
  100. case'w':
  101. if (pos.y == 0)
  102. cout << "You can't climb any higher!";
  103. else
  104. {
  105. pos.y--;
  106. cout << "Moved up";
  107. world[pos.y][pos.x] = ' ';
  108. }
  109. break;
  110. case's':
  111. if (pos.y == 14)
  112. cout << "you can't dig that low, ya doofus!" << endl;
  113. else
  114. {
  115. pos.y++;
  116. cout << "Moved down" << endl;
  117. world[pos.y][pos.x] = ' ';
  118. }
  119. break;
  120. case'S':
  121. if (world[pos.y+1][pos.x] == 'W')
  122. {
  123. cout << "dug dirt!" << endl;
  124. world[pos.y+1][pos.x] = ' ';
  125. dirt++;
  126. }
  127. else
  128. cout << "nothing to dig!" << endl;
  129. break;
  130. case'd':
  131. if (pos.x == 14)
  132. cout << "You hit an unbreakable wall you cannot break through" << endl;
  133. else
  134. {
  135. pos.x++;
  136. cout << "Moved Right" << endl;
  137. world[pos.y][pos.x] = ' ';
  138. }
  139. break;
  140.  
  141. case'a':
  142. if (pos.x == 0)
  143. cout << "You hit an unbreakable wall you cannot break through" << endl;
  144. else
  145. {
  146. pos.x--;
  147. cout << "Moved Right" << endl;
  148. world[pos.y][pos.x] = ' ';
  149. }
  150. break;
  151. case'z':
  152. if(world[pos.y+1][pos.x] == ' ')
  153. pos.Sand();
  154. break;
  155. default:
  156. cout << "dont be hurr";
  157. }
  158.  
  159. }while (health != 0);
  160. cin >> i;
  161. return 0;
  162. }
Add Comment
Please, Sign In to add comment