Friday 26 June 2009

c++ Tic Tac Toe script

#include //you need to use >< on the headers, I can't use them at this page
#include
#include
#include
#include
#include
using namespace std;
HANDLE SetColor(
HANDLE console,
int fg = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY,
int bg = 0)

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

SetConsoleTextAttribute(console, fg | bg);
return console;
}


int main()
{
char Csquare1('1');
char Csquare2('2');
char Csquare3('3');
char Csquare4('4');
char Csquare5('5');
char Csquare6('6');
char Csquare7('7');
char Csquare8('8');
char Csquare9('9');
int PlayerTurn(1);
bool GameOverWin(false);
bool GameOver(false);

do {
HANDLE console = SetColor(NULL, FOREGROUND_RED, FOREGROUND_INTENSITY);
cout << playerturn ="=" cplayermark =" 'X';" cplayermark =" 'O';">> NextMove;
bValidMove = true;

if(NextMove == '1' && Csquare1 == '1') {
Csquare1 = cPlayerMark;
} else if (NextMove == '2' && Csquare2 == '2') {
Csquare2 = cPlayerMark;
} else if (NextMove == '3' && Csquare3 == '3') {
Csquare3 = cPlayerMark;
} else if (NextMove == '4' && Csquare4 == '4') {
Csquare4 = cPlayerMark;
} else if (NextMove == '5' && Csquare5 == '5') {
Csquare5 = cPlayerMark;
} else if (NextMove == '6' && Csquare6 == '6') {
Csquare6 = cPlayerMark;
} else if (NextMove == '7' && Csquare7 == '7') {
Csquare7 = cPlayerMark;
} else if (NextMove == '8' && Csquare8 == '8') {
Csquare8 = cPlayerMark;
} else if (NextMove == '9' && Csquare9 == '9') {
Csquare9 = cPlayerMark;
} else {
cout << "Invalid move, try again" << bvalidmove =" false;" csquare2 ="="" csquare3 ="="" gameoverwin =" true;" csquare4 ="="" csquare7 ="="" gameoverwin =" true;" csquare5 ="="" csquare9 ="="" gameoverwin =" true;" csquare6 ="="" csquare9 ="="" gameoverwin =" true;" csquare5 ="="" csquare7 ="="" gameoverwin =" true;" csquare2 ="="" csquare8 ="="" gameoverwin =" true;" csquare4 ="="" csquare6 ="="" gameoverwin =" true;" csquare8 ="="" csquare7 ="="" gameoverwin =" true;" gameover =" true;" playerturn ="="" playerturn =" 2;" playerturn =" 1;">

C++ color script

#include iostream //you need to use >< on the headers, I can't use them at this page
#include windows.h

using namespace std;

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

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

SetConsoleTextAttribute(console, fg | bg);

return console;
}


int main()
{
HANDLE console = SetColor(NULL, FOREGROUND_GREEN, FOREGROUND_RED);
cout << "Hello World" << console =" SetColor(NULL," console =" SetColor(NULL,">