Advertisement
kanciastopantalones

Untitled

Mar 19th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include <conio.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. void gotoxy(int x, int y)
  5. {
  6. COORD c;
  7. c.X = x - 1;
  8. c.Y = y - 1;
  9. SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
  10. }
  11.  
  12.  
  13. void main() {
  14. int x=10,y=10,dx=1,dy=1,px=36,py=25,i,j,st1=1,st2=1;
  15. int tab[85][27];
  16. long k;
  17. char c='x';
  18.  
  19.  
  20. for(i=1;i<80;i=i+1)
  21. {
  22. for(j=1;j<27;j=j+1)
  23. {
  24. tab[i][j]='o';
  25. if((i%6==0) && (j%4==0) && (j<15))
  26. {
  27. tab[i][j]=1;
  28. gotoxy(i,j);
  29. printf("X");
  30.  
  31. }
  32.  
  33. }
  34. }
  35.  
  36.  
  37.  
  38.  
  39.  
  40. while(c!='k'){
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. gotoxy(px,25);
  49. printf(" ====== ");
  50. if(c=='a'){
  51. if (px>1){
  52.  
  53. px=px-1;
  54. gotoxy(px,25);
  55. printf(" ====== ");}
  56. }
  57. if(c=='d'){
  58.  
  59. if (px<72){
  60. px=px+1;
  61. gotoxy(px,25);
  62. printf(" ====== ");}
  63. }
  64.  
  65. c='x';
  66.  
  67.  
  68. gotoxy(x,y);
  69. printf("%c",c);
  70.  
  71.  
  72. if ((y==24) && ((x>=px+1) && (x<=px+7)))dy=-dy;
  73.  
  74. if ((x==80) || (x==1))dx=-dx;
  75. if ((y==25) || (y==1))dy=-dy;
  76.  
  77.  
  78.  
  79. if (tab[x][y]==1)
  80. {
  81. dy=-dy;
  82. tab[x][y]=0;
  83. }
  84.  
  85.  
  86.  
  87. for(k=0;k<100000000;k++);
  88.  
  89. gotoxy(x,y);
  90. printf(" ");
  91.  
  92. x+=dx;
  93. y+=dy;
  94.  
  95. if (kbhit())
  96. c=getch();
  97.  
  98. if (y==25)
  99. {
  100. c='k';
  101. }
  102.  
  103.  
  104.  
  105. }
  106.  
  107. for(i=1;i<=80;i=i+1)
  108. {
  109. for(j=1;j<=25;j=j+1)
  110. {
  111.  
  112. gotoxy(i,j);
  113. printf(" ");
  114.  
  115.  
  116. }
  117. }
  118.  
  119. gotoxy(15,10);
  120. printf("DYNTKA ZIOMUS GEJM OVER ZIOMUS TRY AGAIN ZIOMUS");
  121.  
  122.  
  123. getchar();
  124.  
  125.  
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement