1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#include <Windows.h>
#include <cstdio>
const char shapes[][8] =
{
{0x18,0x24,0x42,0x42,0x7E,0x42,0x42,0x42}, //a
{0x7C,0x42,0x42,0x7C,0x42,0x42,0x42,0x7C}, //b
{0x1C,0x22,0x40,0x40,0x40,0x40,0x22,0x1C}, //c
{0x78,0x44,0x42,0x42,0x42,0x42,0x44,0x78}, //d
{0x7E,0x40,0x40,0x7C,0x40,0x40,0x40,0x7E}, //e
{0x7E,0x40,0x40,0x7C,0x40,0x40,0x40,0x40}, //f
{0x1C,0x22,0x40,0x40,0x4E,0x42,0x22,0x1C}, //g
{0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42}, //h
{0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x7C}, //i
{0x3E,0x04,0x04,0x04,0x04,0x24,0x24,0x38}, //j
{0x42,0x44,0x48,0x70,0x48,0x44,0x42,0x42}, //k
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7E}, //L
{0x6C,0x92,0x92,0x92,0x82,0x82,0x82,0x82}, //M
{0x42,0x62,0x52,0x52,0x4A,0x4A,0x46,0x42}, //N
{0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x3C}, //O
{0x7C,0x42,0x42,0x7C,0x40,0x40,0x40,0x40}, //P
{0x3C,0x42,0x42,0x42,0x42,0x4A,0x44,0x3A}, //Q
{0x3C,0x42,0x42,0x42,0x7C,0x44,0x42,0x42}, //R
{0x3C,0x42,0x40,0x3C,0x02,0x02,0x42,0x3C}, //S
{0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10}, //T
{0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C}, //U
{0x42,0x42,0x44,0x44,0x48,0x48,0x50,0x20}, //V
{0x82,0x82,0x82,0x82,0x54,0x54,0x54,0x28}, //W
{0x42,0x24,0x24,0x18,0x18,0x24,0x24,0x42}, //X
{0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10}, //Y
{0x7E,0x02,0x04,0x08,0x10,0x20,0x40,0x7E} //Z
};
const char* words[] = {
" ",
" you ",
" know ",
" this ",
" boogie ",
" is ",
" for ",
" real ",
" ",
" nothing",
" left ",
" for ",
" me ",
" to ",
" do ",
" but ",
" dance ",
" dance ",
" ",
" got ",
" canned ",
" heat ",
" in ",
" my ",
" heels ",
" tonight",
" baby "
};
const int maxwords = 27;
char data[8][64];
int pos[8];
int nextword;
int direction;
auto hand = GetStdHandle( STD_OUTPUT_HANDLE );
void loadword()
{
for(int y = 0; y < 8; ++y)
{
for(int x = 0; x < 64; ++x)
{
data[y][x] = shapes[words[nextword][x>>3]-'a'][y] & (1<<(7^x&7)) ? (nextword == 17 ?' ':'#') : (nextword != 17 ?' ':'#');
}
}
}
void setpos()
{
for(int i = 0; i < 8; ++i)
pos[i] = direction > 0 ? -i : 64+i;
}
int main()
{
nextword = 1;
loadword();
nextword = 2;
direction = 1;
setpos();
COORD c;
while(!GetAsyncKeyState(VK_RETURN))
{
for(c.Y = 0; c.Y < 8; ++c.Y)
{
c.X = pos[c.Y]-direction;
if(c.X >= 0 && c.X < 64)
{
SetConsoleCursorPosition(hand,c);
printf("%c",data[c.Y][c.X]);
}
c.X = pos[c.Y];
if(c.X >= 0 && c.X < 64)
{
SetConsoleCursorPosition(hand,c);
printf("*");
}
}
Sleep(10);
for(int i = 0; i < 8; ++i) pos[i] += direction;
if((pos[7] < -1 && direction < 0) || (pos[7] >= 65 && direction > 0))
{
loadword();
nextword = (nextword+1) % maxwords;
direction=-direction;
Sleep(200);
setpos();
}
}
}
|