Advertisement
tei123

wonszzeczny ogon

Mar 22nd, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.70 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include "windows.h"
  5. #include <time.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10.  
  11. void gotoxy(int x, int y)
  12. {
  13. COORD c;
  14. c.X = x - 1;
  15. c.Y = y - 1;
  16. SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
  17. }
  18.  
  19. int main(int argc, char *argv[])
  20. {
  21. srand(time(NULL));
  22.  
  23. char men;
  24. system("CLS");
  25. cout<<" Witaj w grze Wonsz \276eczny" << endl;
  26. cout << "1. Zagraj w gr\251" << endl;
  27. cout << "2. Wy\210\245cz gr\251" << endl;
  28. cout << endl;
  29. cout << endl;
  30. cout << "Instrukcja: "<< endl;
  31. cout << "Jedz zielone" << endl;
  32. cout << "Nie jedz czerwonych" << endl;
  33. cout << "Nie jedz pude\210ka" << endl;
  34. men = getch();
  35. if (men=='1')
  36. system("pause");
  37. if (men=='2')
  38. return 0;
  39. HANDLE hConsole;
  40. hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  41. int a, b;
  42. system("CLS");
  43. gotoxy(25,10);
  44. cout<<"Wonsz \276eczny";
  45.  
  46. gotoxy(1,15);//trzecia ramka
  47. cout<<char(218);
  48. for(int i=0; i<78; i++)
  49. cout<<char(196);
  50. cout<<char(191);
  51. for(int i=0; i<15; i++)
  52. {
  53. gotoxy(0,i+15);
  54. if(i==14) cout<<char(192);
  55. else cout<<char(179)<<endl;
  56. }
  57. gotoxy(2,30);
  58. for(int i=0; i<78; i++)
  59. cout<<char(196);
  60. gotoxy(79,19);
  61. for(int i=0; i<15; i++)
  62. {
  63. gotoxy(80,i+16);
  64. if(i==14) cout<<char(217);
  65. else cout<<char(179)<<endl;
  66. }
  67.  
  68. int u1,m2;
  69. u1=rand()%80;
  70. m2=rand()%15+15;
  71. gotoxy(u1,m2);
  72. SetConsoleTextAttribute(hConsole, 4);
  73. cout << "X";
  74. SetConsoleTextAttribute(hConsole, 7);
  75.  
  76.  
  77. int u,m;
  78. u=rand()%80;
  79. m=rand()%15+15;
  80. gotoxy(u,m);
  81. SetConsoleTextAttribute(hConsole, 2);
  82. cout << "X";
  83. SetConsoleTextAttribute(hConsole, 7);
  84.  
  85. int znak;
  86. int x=20,y=20;
  87. gotoxy(x,y);
  88. cout<<"@";
  89. int key;
  90. int pkt=1;
  91.  
  92. do
  93. {
  94.  
  95. key = getch();
  96. if (key == 224 || key ==0 )
  97. {
  98. switch (getch ())
  99. {
  100. case 80 : y++;gotoxy(x,y); cout<<"@"; //dol
  101. gotoxy(x,y-pkt); cout << " ";
  102.  
  103.  
  104. break;
  105. case 72 : y--;gotoxy(x,y); cout<<"@"; //gora
  106. gotoxy(x,y+pkt); cout << " ";
  107. break;
  108. case 77 : x++;gotoxy(x,y); cout<<"@"; //prawo
  109. gotoxy(x-pkt,y); cout << " ";
  110.  
  111. break;
  112. case 75 : x--;gotoxy(x,y); cout<<"@"; //lewo
  113. gotoxy(x+pkt,y); cout << " ";
  114.  
  115.  
  116. break;
  117. }
  118. }
  119. if ((y == 15)||(y==30)||(x==80)||(x==1)){system ("cls");
  120. cout << "PRZEGRANA! Wonsz \276eczny by\210 zbyt niebezpieczny!"<<endl;
  121.  
  122. cout << "Liczba uzyskanych punktow: " << pkt-1<<endl;
  123. cout << " _______________________________________________________ "<<endl;
  124. cout << "| | "<<endl;
  125. cout << "| Ha ha, you're dead | "<<endl;
  126. cout << "|_________ ________________________________| "<<endl;
  127. cout << " |_ __/ ___---------__ "<<endl;
  128. cout << " | _/ / |_ "<<endl;
  129. cout << " | / / | "<<endl;
  130. cout << " | / | _ _ \ | "<<endl;
  131. cout << " | | / / | / | | | "<<endl;
  132. cout << " | | || || || | "<<endl;
  133. cout << " | | | |_//\|_/ | | "<<endl;
  134. cout << " | | |_| (||) |_______| | "<<endl;
  135. cout << " | | | || | _ / / | "<<endl;
  136. cout << " | | |_________|| \/ / / "<<endl;
  137. cout << " | |_ |_|_|_|_|/| _/___/ "<<endl;
  138. cout << " |__> _ _/_ _ / | "<<endl;
  139. cout << " .|_|_|_|_| | "<<endl;
  140. cout << " | / "<<endl;
  141. cout << " |__________/ "<<endl;
  142.  
  143. cout << "ESC aby wyj\230\206";
  144. };
  145.  
  146. if ((y==m)&&(x==u))
  147. {
  148. u=rand()%79+1;
  149. m=rand()%15+15;
  150. gotoxy(u,m);
  151. SetConsoleTextAttribute(hConsole, 2);
  152. cout << "X";
  153. SetConsoleTextAttribute(hConsole, 7);
  154. pkt=pkt+1;
  155. gotoxy(u1,m2);
  156. cout << " ";
  157. u1=rand()%80;
  158. m2=rand()%15+15;
  159. gotoxy(u1,m2);
  160. SetConsoleTextAttribute(hConsole, 4);
  161. cout << "X";
  162. SetConsoleTextAttribute(hConsole, 7);
  163.  
  164.  
  165. gotoxy(25,12);
  166. cout << "Liczba uzyskanych punktow: " << pkt-1;
  167. };
  168. if ((y==m2)&&(x==u1))
  169. {
  170. system("cls");
  171. cout << "PRZEGRANA! Wonsz \276eczny by\210 zbyt niebezpieczny!"<<endl;
  172. cout << "Liczba uzyskanych punktow: " << pkt-1<<endl;
  173.  
  174. cout << " _______________________________________________________ "<<endl;
  175. cout << "| | "<<endl;
  176. cout << "| Ha ha, you're dead | "<<endl;
  177. cout << "|_________ ________________________________| "<<endl;
  178. cout << " |_ __/ ___---------__ "<<endl;
  179. cout << " | _/ / |_ "<<endl;
  180. cout << " | / / | "<<endl;
  181. cout << " | / | _ _ \ | "<<endl;
  182. cout << " | | / / | / | | | "<<endl;
  183. cout << " | | || || || | "<<endl;
  184. cout << " | | | |_//\|_/ | | "<<endl;
  185. cout << " | | |_| (||) |_______| | "<<endl;
  186. cout << " | | | || | _ / / | "<<endl;
  187. cout << " | | |_________|| \/ / / "<<endl;
  188. cout << " | |_ |_|_|_|_|/| _/___/ "<<endl;
  189. cout << " |__> _ _/_ _ / | "<<endl;
  190. cout << " .|_|_|_|_| | "<<endl;
  191. cout << " | / "<<endl;
  192. cout << " |__________/ "<<endl;
  193.  
  194. cout << "ESC aby wyj\230\206";
  195. };
  196.  
  197. if (key==27)break;
  198. /*
  199.  
  200. */
  201.  
  202. ;
  203. }
  204.  
  205. while (true);
  206.  
  207.  
  208. //system ("PAUSE")
  209. return 0;
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement