Advertisement
tei123

wunsz

Mar 9th, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include "windows.h"
  5.  
  6. using namespace std;
  7.  
  8. void gotoxy(int x, int y)
  9. {
  10. COORD c;
  11. c.X = x - 1;
  12. c.Y = y - 1;
  13. SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
  14. }
  15.  
  16. int main(int argc, char *argv[])
  17. {
  18. int a, b;
  19. gotoxy(25,10);
  20. cout<<"Witamy w Grze o nazwie WONSZ!!!!!";
  21.  
  22. gotoxy(1,15);//trzecia ramka
  23. cout<<char(218);
  24. for(int i=0; i<78; i++)
  25. cout<<char(196);
  26. cout<<char(191);
  27. for(int i=0; i<15; i++)
  28. {
  29. gotoxy(0,i+15);
  30. if(i==14) cout<<char(192);
  31. else cout<<char(179)<<endl;
  32. }
  33. gotoxy(2,30);
  34. for(int i=0; i<78; i++)
  35. cout<<char(196);
  36. gotoxy(79,19);
  37. for(int i=0; i<15; i++)
  38. {
  39. gotoxy(80,i+16);
  40. if(i==14) cout<<char(217);
  41. else cout<<char(179)<<endl;
  42. }
  43.  
  44. int znak;
  45. int x=20,y=20;
  46. gotoxy(x,y);
  47. cout<<"@";
  48. int key;
  49.  
  50.  
  51. do
  52. {
  53.  
  54. key = getch();
  55. if (key == 224 || key ==0 )
  56. {
  57. switch (getch ())
  58. {
  59. case 80 : y++;gotoxy(x,y); cout<<"@";
  60. gotoxy(x,y-1); cout << " ";
  61. break;
  62. case 72 : y--;gotoxy(x,y); cout<<"@";
  63.  
  64. gotoxy(x,y+1); cout << " ";
  65. break;
  66. case 77 : x++;gotoxy(x,y); cout<<"@";
  67.  
  68. gotoxy(x-1,y); cout << " ";
  69. break;
  70. case 75 : x--;gotoxy(x,y); cout<<"@";
  71.  
  72. gotoxy(x+1,y); cout << " ";
  73.  
  74. break;
  75. }
  76. }
  77. if ((y == 15)||(y==30)||(x==80)||(x==1)||key==27)break;
  78. }
  79. while (true);
  80. //system ("PAUSE")
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement