Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #define S(X,Y,C,A){b[Y][X][0]=C;b[Y][X][1]=A;}
- #define D(K)GetAsyncKeyState(K)&(1<<16)
- #define W while
- #define R int
- void* h;
- short b[70][90][2];
- R x, y, a, Z=37, V, B, L=0, E, G, e[15], K;
- INT64 s[3]={0x42247E5AFFBDA542,0x183C7EDBFF245AA5,0x2418BDDBBD99C300};
- void d(R N, R M, INT64 g,R o) {
- W(g) {
- y=8;
- W(y--) {
- if(!o || g & 1)
- S(N, M, (g & 1) ? 219 : 32, a);
- N++;
- g>>=1;
- }
- N -= 8;
- M--;
- }
- }
- void t(R N, R M, char* T) {
- while(*T) {
- S(N, M, *T, a);
- N++;
- T++;
- }
- }
- void m() {
- SMALL_RECT r{0, 0, 90, 70};
- WriteConsoleOutput(h, (const CHAR_INFO*)&b, COORD{90, 70}, COORD{0, 0}, &r);
- }
- R main() {
- h = GetStdHandle(-11);
- // Reset
- r:
- E=G=B=K=0;
- ZeroMemory(&e,60);
- l:
- // ClearScreen
- x=6300;
- W(x--)
- S(x, 0, 0, 0);
- // HandleInput
- Z+=D(65)?-1:D(68)?1:0;
- Z = Z < 0 ? 0 : Z > 80 ? 80 : Z;
- if(D(32) && !B) {
- Beep(500, 30);
- V = Z + 2;
- B = 62;
- }
- if(!B)
- V=-1;
- else
- B--;
- // DrawPlayer
- a = 10;
- d(Z, 65, 0x40E1F,0);
- if(B>=0)
- S(V, B, 64, 13);
- // DrawEnemies
- if(G++ % 2)
- E++;
- R k=E/13,j=E%13;
- R X = k % 2 ? (13 - j) : j;
- R Y = k;
- x=15;
- W(x--) {
- if(!e[x]) {
- a = x%2+14-L;
- R U = X + x%5 * 16, I = Y + 8 + x/5 * 10;
- d(U, I, s[(L+(a&1))%3],0);
- if(V>U&&V<U+8&&B>I-8&&B<I) {
- e[x] = 1;
- B=0;
- if(++K==15) {
- // Win
- x=6300;
- W(x--)
- S(x, 0, 219, (x&((L+1)*4%15)));
- a = 14;
- x=2;W(x--)d(35+x*5,35,0xE010D090E0,1);
- char h[7]="Lvl: ";
- h[5] ='0'+ ++L;
- t(40, 37, &h[0]);
- m();
- x=6;
- W(x--)
- Beep(x&1?200:300, 300);
- goto r;
- }
- }
- if(I > 62) {
- x=4;
- W(x--)
- Beep(210+x*10, x?300:1000);
- L=0;
- goto r;
- }
- }
- }
- m();
- Sleep(40-L*4);
- goto l;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment