Advertisement
kanciastopantalones

arkanoid new

Mar 20th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 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,t,wynik=0;
  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. t=1+rand()%3;
  28. tab[i][j]=t;
  29. gotoxy(i,j);
  30. printf("%d", t);
  31.  
  32. }
  33.  
  34. }
  35.  
  36.  
  37. }
  38.  
  39. for(i=1;i<26;i=i+1)
  40. {
  41. gotoxy(81,i);
  42. printf("|");
  43. }
  44.  
  45.  
  46.  
  47.  
  48. while(c!='k'){
  49.  
  50.  
  51.  
  52.  
  53. for(k=0;k<2;k++)
  54. {
  55. if (kbhit())
  56. c=getch();
  57.  
  58. gotoxy(px,25);
  59. printf(" ====== ");
  60. if(c=='a'){
  61. if (px>1){
  62.  
  63. px=px-1;
  64. gotoxy(px,25);
  65. printf(" ====== ");}
  66. }
  67. if(c=='d'){
  68.  
  69. if (px<72){
  70. px=px+1;
  71. gotoxy(px,25);
  72. printf(" ====== ");}
  73. }
  74. }
  75.  
  76. c='x';
  77.  
  78.  
  79. gotoxy(x,y);
  80. printf("%c",c);
  81.  
  82.  
  83. if ((y==24) && ((x>=px+1) && (x<=px+7)))dy=-dy;
  84.  
  85. if ((x==80) || (x==1))dx=-dx;
  86. if ((y==25) || (y==1))dy=-dy;
  87.  
  88.  
  89.  
  90. if (tab[x][y]==1)
  91. {
  92. dy=-dy;
  93. tab[x][y]=0;
  94. wynik=wynik+1;
  95. }
  96. if (tab[x][y]==2)
  97. {
  98. dy=-dy;
  99. tab[x][y]=0;
  100. wynik=wynik+2;
  101. }
  102. if (tab[x][y]==3)
  103. {
  104. dy=-dy;
  105. tab[x][y]=0;
  106. wynik=wynik+3;
  107. }
  108.  
  109.  
  110. for(k=0;k<50000000;k++);
  111. gotoxy(86,1);
  112. printf("Twoj wynik: %d ", wynik);
  113. gotoxy(x,y);
  114. printf(" ");
  115.  
  116. x+=dx;
  117. y+=dy;
  118.  
  119.  
  120.  
  121. if (y==25)
  122. {
  123. c='k';
  124. }
  125.  
  126.  
  127.  
  128. }
  129.  
  130. for(i=1;i<=80;i=i+1)
  131. {
  132. for(j=1;j<=25;j=j+1)
  133. {
  134.  
  135. gotoxy(i,j);
  136. printf(" ");
  137.  
  138.  
  139. }
  140. }
  141.  
  142.  
  143. gotoxy(15,10);
  144. printf("Koniec");
  145.  
  146.  
  147.  
  148. getchar();
  149.  
  150.  
  151.  
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement