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
|
#include <windows.h>
#include <string>
using namespace std;
//Derp, forgot to put this in, so...
#define off {CONSOLE_CURSOR_INFO cci={50,false};SetConsoleCursorInfo(out,&cci);}
//
const
unsigned int
mspf=500;DWORD read;
string tree;
HANDLE out=GetStdHandle
(STD_OUTPUT_HANDLE);WORD clrs[]
={FOREGROUND_RED,FOREGROUND_RED|
FOREGROUND_GREEN,
FOREGROUND_RED|FOREGROUND_GREEN
|FOREGROUND_BLUE};COORD xy[8]={{5,0},{4,1},
{6,2},{3,3},{7,3},{5,4},
{1,5},{7,5}};string repeat(char c,
unsigned num){string tmp;for(;num>0;--num
){tmp+=c;}return tmp;}struct
x_mas{x_mas(){SetConsoleTextAttribute
(out,FOREGROUND_GREEN);tree+=repeat(' ',11);
tree[5]='#';tree[6]='\n';tree+="*|\\\n";tree+=repeat(
' ',3)+repeat('/',2);tree+="\\*\\\n"
+repeat(' ',2);tree+="/*/\\|*\\\n ";tree+=
repeat('/',2)+repeat('\\',2);tree+="*|"+repeat('\\'
,3);tree+="\n/*\\|/"+repeat('\\',2)+"*\\/\\\n";tree+=repeat
(' ',11);tree[61]=tree[63]='|';
tree[62]='_';}}xmas;int main(){off unsigned ticks=
GetTickCount(),trigger,x;SetConsoleTitle("Merry Christmas!");
srand(GetTickCount());WriteConsole(out,tree.c_str(),tree.length(),&read,
NULL);SetConsoleTextAttribute(out,clrs[2]
);WriteConsole(out,"\n\nPress <ENTER> to exit",23,&read,
NULL);while(!(GetAsyncKeyState(VK_RETURN)>>7)){ticks=GetTickCount();
if(ticks>trigger){trigger=ticks+mspf;for(x=0;x<8;++x){WriteConsoleOutputAttribute
(out,clrs+rand()
%3,1,xy[x],&read
);}}}return 0;}
|