Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include <iterator>
  3. #include <conio.h>
  4. #include <windows.h>
  5. #include <list>
  6.  
  7. using namespace std;
  8.  
  9. long long n, m, a=1, b=1, t;
  10. string name1;
  11. char c, mp[100][100], mp_npc[100][100];
  12.  
  13. void setcur(int x, int y) // ????? ??? ????????
  14. {
  15. COORD coord;
  16. coord.X = x;
  17. coord.Y = y;
  18. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  19. }
  20.  
  21. void hod(char c2){
  22. if (c2 == 'd'){
  23. if (mp[a][b+1] == ' '){
  24. mp[a][b+1] = char(2);
  25. mp[a][b] = ' ';
  26. b ++;
  27. }
  28. if (mp[a][b+1] == char(3)){
  29. mp[a][b+1] = char(2);
  30. mp[a][b] = ' ';
  31. b ++;
  32. m ++;
  33. }
  34. }
  35. if (c2 == 's'){
  36. if (mp[a+1][b] == ' '){
  37. mp[a+1][b] = char(2);
  38. mp[a][b] = ' ';
  39. a ++;
  40. }
  41. if (mp[a+1][b] == char(3)){
  42. mp[a+1][b] = char(2);
  43. mp[a][b] = ' ';
  44. a ++;
  45. m ++;
  46. }
  47. }
  48. if (c2 == 'a'){
  49. if (mp[a][b-1] == ' '){
  50. mp[a][b-1] = char(2);
  51. mp[a][b] = ' ';
  52. b --;
  53. }
  54. if (mp[a][b-1] == char(3)){
  55. mp[a][b-1] = char(2);
  56. mp[a][b] = ' ';
  57. b --;
  58. m ++;
  59. }
  60. }
  61. if (c2 == 'w'){
  62. if (mp[a-1][b] == ' '){
  63. mp[a-1][b] = char(2);
  64. mp[a][b] = ' ';
  65. a --;
  66. }
  67. if (mp[a-1][b] == char(3)){
  68. mp[a-1][b] = char(2);
  69. mp[a][b] = ' ';
  70. a --;
  71. m ++;
  72. }
  73. }
  74. return ;
  75. }
  76. void dv(){
  77.  
  78. for (int i=1; i < 19; i ++){
  79. for (int j=0; j < 30; j ++){
  80. if (mp[i-1][j] == char(3)){
  81. mp[i][j] = '9';
  82. mp[i-1][j] = ' ';
  83. }
  84. }
  85. }
  86. for (int i=1; i < 19; i ++){
  87. for (int j=0; j < 30; j ++){
  88. if (mp[i][j] == '9'){
  89. mp[i][j] = char(3);
  90. }
  91. }
  92. }
  93.  
  94. }
  95. int main() {
  96. srand (time(NULL));
  97.  
  98. cout << "enter the name of player :: ";
  99. cin >> name1;
  100. for (int i=0; i < 20; i ++){
  101. for (int j=0; j < 30; j ++){
  102. if (i == 0 || j == 0 || i == 19 || j == 29){
  103. mp[i][j] = '0';
  104. }else {
  105. if (rand() % (i+j) == 0){
  106. mp[i][j] = char(3);
  107. }else
  108. mp[i][j] = ' ';
  109. }
  110. }
  111. }
  112. mp[a][b] = char(2);
  113. while (true) {
  114. c = _getch();
  115. hod(c);
  116. setcur(0,1);
  117. for (int i=0; i < 20; i ++){
  118. for (int j=0; j < 30; j ++){
  119. cout << mp[i][j];
  120. }
  121. if (i == 10){
  122. cout << " " << char(3) << " = " << m;
  123. }
  124. cout << endl;
  125. }
  126. dv();
  127. }
  128.  
  129. return 0;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement