Guest User

Untitled

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