Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. #include <windows.h>
  4.  
  5.  
  6. void gotoxy(int x, int y);
  7. void lftrght(char ch, int colStart, int row, int colFinish);
  8. void rghtlft(char ch, int colStart, int row, int colFinish);
  9. void topbot(char ch, int colStart, int row, int colFinish);
  10. void bottop(char ch, int colStart, int row, int colFinish);
  11.  
  12. int main()
  13. {
  14. int left = 0;
  15. int right = 78;
  16. int bot= 12;
  17. int up= 12;
  18.  
  19. for ( int snake=0; snake<39;snake++)
  20. {
  21. int left1=left-1;
  22. int right1= right+1;
  23. int bot1= bot-1;
  24. int up1= up-1;
  25.  
  26. int col=left;
  27. gotoxy(col,up);
  28. cout<<">";
  29. Sleep(10);
  30. //bot
  31. col= right;
  32.  
  33. gotoxy(col,bot);
  34. cout<<"<";
  35. Sleep(10);
  36. right--;
  37. left ++;
  38.  
  39. col=left1;
  40. gotoxy(col,up);
  41. cout<<"*";
  42. Sleep(10);
  43. //bot
  44. col= right1;
  45.  
  46. gotoxy(col,bot);
  47. cout<<"*";
  48. Sleep(10);
  49. }
  50. left = 0;
  51. right = 79;
  52. bot= 12;
  53. up= 12;
  54. int col=0;
  55.  
  56. for ( int snake=0; snake<39;snake++)
  57. {
  58. col=left;
  59. gotoxy(col,up);
  60. cout<<" ";
  61. Sleep(10);
  62. //bot
  63. col= right;
  64.  
  65. gotoxy(col,bot);
  66. cout<<" ";
  67. Sleep(10);
  68. right--;
  69. left ++;
  70. }
  71. gotoxy(right,bot);
  72. cout<<" ";
  73. Sleep(10);
  74. right--;
  75. gotoxy(right,bot);
  76. cout<<" ";
  77. Sleep(10);
  78. getch();
  79.  
  80. for ( int bob=0; bob<30; bob++)
  81. {
  82. int top=10;
  83. int bottom=12;
  84. int left=38;
  85. int right= 42;
  86. for (int lol=0; lol<6;lol++)
  87. {
  88. //top border left to right
  89. lftrght('*', left,top,right);
  90. // border down the right side
  91. topbot('*', top,right,bottom);
  92. //bottom right to lrft
  93. rghtlft('*',right,bottom,left);
  94.  
  95. // up the left side
  96. bottop('*', bottom,left,top);
  97. Sleep(100);
  98. top--;
  99. left--;
  100. right++;
  101. bottom++;
  102. top--;
  103. left--;
  104. right++;
  105. bottom ++;
  106. }
  107.  
  108. for (int lol=0; lol<7;lol++)
  109. {
  110. //top border left to right
  111. lftrght(' ', left,top,right);
  112. // border down the right side
  113. topbot(' ', top,right,bottom);
  114. //bottom right to lrft
  115. rghtlft(' ',right,bottom,left);
  116.  
  117. // up the left side
  118. bottop(' ', bottom,left,top);
  119. Sleep(100);
  120. top++;
  121. left++;
  122. right--;
  123. bottom--;
  124. top++;
  125. left++;
  126. right--;
  127. bottom --;
  128. }
  129. }
  130. getch();
  131. return 0;
  132. }
  133. void lftrght(char ch, int colStart, int row, int colFinish)
  134. {
  135. //top border left to right
  136. for (int col=colStart; col < colFinish;col++)
  137. {
  138. gotoxy(col,row);
  139. cout<<ch;
  140. }
  141. }
  142. void rghtlft(char ch, int colStart, int row, int colFinish)
  143. {
  144. //top border left to right
  145. for (int col=colStart; col >colFinish;col--)
  146. {
  147. gotoxy(col,row);
  148. cout<<ch;
  149.  
  150. }
  151. }
  152. void topbot(char ch, int colStart, int row, int colFinish)
  153. {
  154. //top border left to right
  155. for (int col=colStart; col <colFinish;col++)
  156. {
  157. gotoxy(row,col);
  158. cout<<ch;
  159.  
  160. }
  161. }
  162. void bottop(char ch, int colStart, int row, int colFinish)
  163. {
  164. //top border left to right
  165. for (int col=colStart; col>colFinish;col--)
  166. {
  167. gotoxy(row,col);
  168. cout<<ch;
  169.  
  170. }
  171. }
  172.  
  173.  
  174.  
  175.  
  176. void gotoxy(int x, int y)
  177. {
  178. COORD coord;
  179. coord.X = x;
  180. coord.Y = y;
  181. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement