Advertisement
tei123

jedzenie

Mar 14th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 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. void gotoxy(int x, int y)
  10. {
  11. COORD c;
  12. c.X = x - 1;
  13. c.Y = y - 1;
  14. SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
  15. }
  16.  
  17.  
  18. int main(int argc, char *argv[])
  19. {
  20. int a, b;
  21. gotoxy(25,10);
  22. cout<<"Witamy w Grze o nazwie WONSZ!!!!!";
  23.  
  24. gotoxy(1,15);//trzecia ramka
  25. cout<<char(218);
  26. for(int i=0; i<78; i++)
  27. cout<<char(196);
  28. cout<<char(191);
  29. for(int i=0; i<15; i++)
  30. {
  31. gotoxy(0,i+15);
  32. if(i==14) cout<<char(192);
  33. else cout<<char(179)<<endl;
  34. }
  35. gotoxy(2,30);
  36. for(int i=0; i<78; i++)
  37. cout<<char(196);
  38. gotoxy(79,19);
  39. for(int i=0; i<15; i++)
  40. {
  41. gotoxy(80,i+16);
  42. if(i==14) cout<<char(217);
  43. else cout<<char(179)<<endl;
  44. }
  45. int u,m;
  46. u=rand()%80;
  47. m=rand()%15+15;
  48. gotoxy(u,m);
  49. cout << "X";
  50. int znak;
  51. int x=20,y=20;
  52. gotoxy(x,y);
  53. cout<<"@";
  54. int key;
  55. int pkt=0;
  56.  
  57. do
  58. {
  59.  
  60. key = getch();
  61. if (key == 224 || key ==0 )
  62. {
  63. switch (getch ())
  64. {
  65. case 80 : y++;gotoxy(x,y); cout<<"@";
  66. gotoxy(x,y-1); cout << " ";
  67. break;
  68. case 72 : y--;gotoxy(x,y); cout<<"@";
  69.  
  70. gotoxy(x,y+1); cout << " ";
  71. break;
  72. case 77 : x++;gotoxy(x,y); cout<<"@";
  73.  
  74. gotoxy(x-1,y); cout << " ";
  75. break;
  76. case 75 : x--;gotoxy(x,y); cout<<"@";
  77.  
  78. gotoxy(x+1,y); cout << " ";
  79.  
  80. break;
  81. }
  82. }
  83. if ((y == 15)||(y==30)||(x==80)||(x==1)){system ("cls");
  84. cout << "PRZEGRANA!"<<endl;
  85. cout << "Liczba uzyskanych punktow: " << pkt;};
  86. if ((y==m)&&(x==u))
  87. {
  88. u=rand()%79+1;
  89. m=rand()%15+15;
  90. gotoxy(u,m);
  91. cout << "X";
  92. pkt=pkt+1;
  93. };
  94. if (key==27)break;
  95. /*
  96.  
  97. */
  98.  
  99. ;
  100. }
  101.  
  102. while (true);
  103.  
  104.  
  105. //system ("PAUSE")
  106. return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement