szymski

Untitled

Aug 21st, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. #define S(X,Y,C,A){b[Y][X][0]=C;b[Y][X][1]=A;}
  4. #define D(K)GetAsyncKeyState(K)&(1<<16)
  5. #define W while
  6. #define R int
  7.  
  8. void* h;
  9. short b[70][90][2];
  10.  
  11. R x, y, a, Z=37, V, B, L=0, E, G, e[15], K;
  12. INT64 s[3]={0x42247E5AFFBDA542,0x183C7EDBFF245AA5,0x2418BDDBBD99C300};
  13.  
  14. void d(R N, R M, INT64 g,R o) {
  15. W(g) {
  16. y=8;
  17. W(y--) {
  18. if(!o || g & 1)
  19. S(N, M, (g & 1) ? 219 : 32, a);
  20. N++;
  21. g>>=1;
  22. }
  23.  
  24. N -= 8;
  25. M--;
  26. }
  27. }
  28.  
  29. void t(R N, R M, char* T) {
  30. while(*T) {
  31. S(N, M, *T, a);
  32. N++;
  33. T++;
  34. }
  35. }
  36.  
  37. void m() {
  38. SMALL_RECT r{0, 0, 90, 70};
  39. WriteConsoleOutput(h, (const CHAR_INFO*)&b, COORD{90, 70}, COORD{0, 0}, &r);
  40. }
  41.  
  42. R main() {
  43. h = GetStdHandle(-11);
  44.  
  45. // Reset
  46. r:
  47. E=G=B=K=0;
  48. ZeroMemory(&e,60);
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. l:
  56.  
  57. // ClearScreen
  58. x=6300;
  59. W(x--)
  60. S(x, 0, 0, 0);
  61.  
  62.  
  63.  
  64.  
  65. // HandleInput
  66. Z+=D(65)?-1:D(68)?1:0;
  67.  
  68. Z = Z < 0 ? 0 : Z > 80 ? 80 : Z;
  69.  
  70. if(D(32) && !B) {
  71. Beep(500, 30);
  72. V = Z + 2;
  73. B = 62;
  74. }
  75.  
  76.  
  77. if(!B)
  78. V=-1;
  79. else
  80. B--;
  81.  
  82.  
  83.  
  84.  
  85. // DrawPlayer
  86. a = 10;
  87.  
  88. d(Z, 65, 0x40E1F,0);
  89.  
  90. if(B>=0)
  91. S(V, B, 64, 13);
  92.  
  93.  
  94.  
  95.  
  96.  
  97. // DrawEnemies
  98. if(G++ % 2)
  99. E++;
  100.  
  101. R k=E/13,j=E%13;
  102.  
  103. R X = k % 2 ? (13 - j) : j;
  104. R Y = k;
  105.  
  106. x=15;
  107. W(x--) {
  108. if(!e[x]) {
  109. a = x%2+14-L;
  110. R U = X + x%5 * 16, I = Y + 8 + x/5 * 10;
  111. d(U, I, s[(L+(a&1))%3],0);
  112. if(V>U&&V<U+8&&B>I-8&&B<I) {
  113. e[x] = 1;
  114. B=0;
  115. if(++K==15) {
  116. // Win
  117. x=6300;
  118. W(x--)
  119. S(x, 0, 219, (x&((L+1)*4%15)));
  120.  
  121. a = 14;
  122. x=2;W(x--)d(35+x*5,35,0xE010D090E0,1);
  123. char h[7]="Lvl: ";
  124. h[5] ='0'+ ++L;
  125. t(40, 37, &h[0]);
  126.  
  127. m();
  128.  
  129. x=6;
  130. W(x--)
  131. Beep(x&1?200:300, 300);
  132.  
  133. goto r;
  134. }
  135. }
  136.  
  137. if(I > 62) {
  138. x=4;
  139. W(x--)
  140. Beep(210+x*10, x?300:1000);
  141. L=0;
  142. goto r;
  143. }
  144. }
  145. }
  146.  
  147. m();
  148.  
  149. Sleep(40-L*4);
  150.  
  151. goto l;
  152.  
  153. return 0;
  154. }
Advertisement
Add Comment
Please, Sign In to add comment