Saturday, 27 March 2010

Matrix script (don't forget to add <> to headers!

#include windows.h // headers
#include iostream.h
#include time.h
#include string.h

using namespace std;

HANDLE SetColor (// color script starts
HANDLE console,
int fg = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
int bg =0)

{
if(console == NULL)
console = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
NULL | NULL | NULL);// color script ends

return console;

}

int main ()
{
int True = 1; // dunno why I have this?
srand(time(0));//random number
while(True = 1) {
int NumBtwo = rand() % 3 + 1;//range for random numbers, this one for color
int NumB = rand() % 160 + 32;//range for random numbers, this one for letter
if (NumB > 126) {// to get more spaces in text
NumB = 32;//ascii sign for space is 32
}
if (NumBtwo == 1) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_GREEN | FOREGROUND_INTENSITY | FOREGROUND_GREEN);//get light green color on character
}

if (NumBtwo == 2) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_GREEN | FOREGROUND_GREEN | FOREGROUND_GREEN);//get dark green character
}

if (NumBtwo == 3) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);//het white character
}

cout << (char)NumB;//disply character
}

return 0;//end!

}//Hope you liked it!!!!