Guest User

Untitled

a guest
Jun 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. using namespace std;
  4.  
  5. void PlaceCursor(const int x, const int y) {
  6.  
  7. HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  8.  
  9. COORD PlaceCursorHere;
  10. PlaceCursorHere.X = x;
  11. PlaceCursorHere.Y = y;
  12.  
  13. SetConsoleCursorPosition(hConsole, PlaceCursorHere);
  14. return;
  15. }
  16.  
  17. void ClearConsole() {
  18.  
  19. HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  20.  
  21. COORD coordScreen = { 0, 0 };
  22. DWORD cCharsWritten;
  23. CONSOLE_SCREEN_BUFFER_INFO csbi;
  24. DWORD dwConSize;
  25.  
  26. if (!GetConsoleScreenBufferInfo(hConsole, &csbi)) { return; }
  27. dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
  28.  
  29. if (!FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten)) { return; }
  30. if (!GetConsoleScreenBufferInfo(hConsole, &csbi)) { return; }
  31. if (!FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten)) { return; }
  32.  
  33. return;
  34. }
  35.  
  36. void Map();
  37. void Creatures();
  38.  
  39. int main(){
  40.  
  41. Map();
  42.  
  43. Creatures();
  44.  
  45. return 0;
  46. }
  47.  
  48. void Map()
  49. {
  50. ClearConsole();
  51. PlaceCursor(0, 0);
  52. cout << (" # # # # \n");
  53. cout << (" ###### # # ########### \n");
  54. cout << (" # # # # \n");
  55. cout << (" # ###### ########### # \n");
  56. cout << (" # # # # \n");
  57. cout << (" # # # # \n");
  58. cout << (" # # # # \n");
  59. cout << (" # # # # \n");
  60. cout << (" # # # # \n");
  61. cout << (" # # ############### # # \n");
  62. cout << (" # # # # # # \n");
  63. cout << (" # ##### ####### # # # \n");
  64. cout << (" # # # # # # \n");
  65. cout << (" ############# # # # # \n");
  66. cout << (" # # # # \n");
  67. cout << (" # # # # \n");
  68. cout << (" ################### # # # \n");
  69. cout << (" # # # # \n");
  70. cout << (" # ################### # # \n");
  71. cout << (" # # # # \n");
  72. cout << (" # # # # \n");
  73. cout << (" # # # # \n");
  74. cout << (" # ######################### # \n");
  75. cout << (" # # \n");
  76. cout << (" ################################# \n");
  77. }
  78.  
  79. void Creatures()
  80. {
  81. int x = 23, y=0;
  82.  
  83. for( ; y!=2 ; y++)
  84. {
  85. PlaceCursor(x, y);
  86. cout << ("O\b");
  87. Sleep( 500 );
  88. cout << (" \b");
  89. }
  90.  
  91. for( ; x!=18 ; x-- )
  92. {
  93. PlaceCursor(x, y);
  94. cout << ("O\b");
  95. Sleep( 500 );
  96. cout << (" \b");
  97. }
  98.  
  99. for( ; y!=12 ; y++) {
  100. PlaceCursor(x, y);
  101. cout << ("O\b");
  102. Sleep( 500 );
  103. cout << (" \b");
  104. }
  105.  
  106. for( ; x!=26 ; x++) {
  107. PlaceCursor(x, y);
  108. cout << ("O\b");
  109. Sleep( 500 );
  110. cout << (" \b");
  111. }
  112.  
  113. for( ; y!=10 ; y--) {
  114. PlaceCursor(x, y);
  115. cout << ("O\b");
  116. Sleep( 500 );
  117. cout << (" \b");
  118. }
  119.  
  120. for( ; x!=36 ; x++) {
  121. PlaceCursor(x, y);
  122. cout << ("O\b");
  123. Sleep( 500 );
  124. cout << (" \b");
  125. }
  126.  
  127. for( ; y!=17 ; y++) {
  128. PlaceCursor(x, y);
  129. cout << ("O\b");
  130. Sleep( 500 );
  131. cout << (" \b");
  132. }
  133.  
  134. for( ; x!=18 ; x--) {
  135. PlaceCursor(x, y);
  136. cout << ("O\b");
  137. Sleep( 500 );
  138. cout << (" \b");
  139. }
  140.  
  141. for( ; y!=23 ; y++) {
  142. PlaceCursor(x, y);
  143. cout << ("O\b");
  144. Sleep( 500 );
  145. cout << (" \b");
  146. }
  147.  
  148. for( ; x!=46 ; x++) {
  149. PlaceCursor(x, y);
  150. cout << ("O\b");
  151. Sleep( 500 );
  152. cout << (" \b");
  153. }
  154.  
  155. for( ; y!=2 ; y--) {
  156. PlaceCursor(x, y);
  157. cout << ("O\b");
  158. Sleep( 500 );
  159. cout << (" \b");
  160. }
  161.  
  162. for( ; x!=36 ; x--) {
  163. PlaceCursor(x, y);
  164. cout << ("O\b");
  165. Sleep( 500 );
  166. cout << (" \b");
  167. }
  168.  
  169. for( ; y!=-1 ; y--) {
  170. PlaceCursor(x, y);
  171. cout << ("O\b");
  172. Sleep( 500 );
  173. cout << (" \b");
  174. }
  175.  
  176. }
Add Comment
Please, Sign In to add comment