source code how to create tristar games using C++

#include
#include
#include
#include
#include
#include
#include

#include"mouse.h"

#define UP 0
#define DOWN 1
#define RIGHT 2
#define LEFT 3
#define RIGHT_UP 4
#define RIGHT_DOWN 5
#define LEFT_UP 6
#define LEFT_DOWN 7

#define PLAYER 0
#define COMPUTER 1

#define YES 1
#define NO 0

void Welcome();
void Screen();
void Marker(int);
void Check(int,int,int);
int Ask_Mouse(int,int);
void Draw_Allowed_Dots(int);
void Convertor(int,int);
void Scorer();
void Press_Exit_Button();
int Computer_Move();
void Write_Status_Game(int);
void Result_Declaration();
void Reset();
int Play();
void Who_Play_First();
void Color_Allotment();

union REGS ii,oo;

int Board[256]=
{ 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9,
9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9,
9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9,
9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9 };


int x,y;
int allowed_square[150],source_square[150],movement_type[150];
int Counter;
int Computer_Color=0;
int Player_Color=0;

int button,mousex,mousey,mousetrap=0;
int reply=1,Whoplays_first=0;
int turn=0,flag_allowed_square_selected=0,flag_no_chance=0;


void main()


// creator- S u ne et sin gh 99 / cse/123 C RS CE M urthal//
this is to protect from thiefs ;-)
{

int gd=DETECT,gm;
initgraph(&gd,&gm,"");

x=getmaxx()/2;
y=getmaxy()/2;

int i;

for(i=0;i<150;i++)
{
allowed_square[i]=0;
source_square[i]=0;
movement_type[i]=0;
}

if(initmouse()==0)
{
closegraph();
restorecrtmode();
cout"\nMouse driver not loaded";
exit(1);
}
restrictmouseptr(1,1,getmaxx()-1,getmaxy()-1);
showmouseptr();
hidemouseptr();


Welcome();
Play();

closegraph();

}

int Play()
{

int o;
int if_over=NO;
int skip=NO;

Who_Play_First();

Screen();

showmouseptr();

Marker(2);
Draw_Allowed_Dots(2);
Marker(1);
Draw_Allowed_Dots(1);

Color_Allotment();

reply=1;
mousetrap=0;

if(Computer_Color!=turn) {
Marker(Player_Color);
Draw_Allowed_Dots(Player_Color);
}
else if(Computer_Color==turn) {
Marker(Computer_Color);
Draw_Allowed_Dots(Computer_Color);
}

Write_Status_Game(Computer_Color);

settextstyle(3,0,1);
setcolor(4);
outtextxy(x-260,y+190,"Reset");
showmouseptr();

while(1)
{
getmousepos(&button,&mousex,&mousey);

if(Computer_Color==turn)
{
hidemouseptr();
reply=Computer_Move();
mousetrap=1;

flag_allowed_square_selected=0;
flag_no_chance=1;

for(o=0;o<150;o++)
{
if(allowed_square[o]==reply)
flag_allowed_square_selected=1;
if(allowed_square[o]!=0)
flag_no_chance=0;
}
if(flag_no_chance==1)
{
if(turn==1)
turn=2;
else if(turn==2)
turn=1;
Draw_Allowed_Dots(0);
Marker(turn);
Screen();
Draw_Allowed_Dots(turn);
mousetrap=0;
showmouseptr();
}
if(flag_allowed_square_selected==0)
{
mousetrap=0;
showmouseptr();
}
showmouseptr();
}

if((button&1)==1)
{
hidemouseptr();
while((button&1)==1)
{
getmousepos(&button,&mousex,&mousey);
mousetrap=1;
}
getmousepos(&button,&mousex,&mousey);

if(Computer_Color!=turn)
reply=Ask_Mouse(mousex,mousey);
else
{
mousetrap=0;
skip=YES;
}
if(skip==NO)
{
if(reply==555)
{
hidemouseptr();
Press_Exit_Button();
exit(0);
}
if(reply==333)
{
hidemouseptr();
Reset();
showmouseptr();
Play();
}

flag_allowed_square_selected=0;
flag_no_chance=1;

for(o=0;o<150;o++)
{
if(allowed_square[o]==reply)
flag_allowed_square_selected=1;
if(allowed_square[o]!=0)
flag_no_chance=0;
}
if(flag_no_chance==1)
{
if(turn==1)
turn=2;
else if(turn==2)
turn=1;
Draw_Allowed_Dots(0);
Marker(turn);
Screen();
Draw_Allowed_Dots(turn);
mousetrap=0;
showmouseptr();
}
if(flag_allowed_square_selected==0)
{
mousetrap=0;
showmouseptr();
}
}
showmouseptr();
}

if(mousetrap==1)
{
hidemouseptr();
Draw_Allowed_Dots(0);
mousetrap=0;
Convertor(reply,turn);
if(turn==1)
turn=2;
else if(turn==2)
turn=1;
Marker(turn);
if(Counter==0)
if_over++;
else
if_over=0;
Screen();
Draw_Allowed_Dots(turn);
Scorer();
int cc=0;
for(o=0;o<256;o++)
{
if(Board[o]!=0)
cc++;
}
if(cc==256||if_over>=3)
Result_Declaration();
showmouseptr();
}
}
}

int Computer_Move()
{
int store_c=Counter;
int store_sqr;
int flag=1;
int stage=0;

for(int o=0;o<256;o++)
if(Board[o]==0)
stage++;

Marker(Computer_Color);

for(o=0;o
{

if(allowed_square[o]==3||allowed_square[o]==48||allowed_square[o]==63||allowed_square[o]==12)
{ return(allowed_square[o]); }

if(allowed_square[o]==192||allowed_square[o]==243||allowed_square[o]==207||allowed_square[o]==252)
{ return(allowed_square[o]); }
}

for(o=0;o
{
if(allowed_square[o]==18 && Board[3]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==33 && Board[48]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==29 && Board[12]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==46 && Board[63]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==209 && Board[192]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==226 && Board[243]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==222 && Board[207]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==237 && Board[252]!=0)
{ return(allowed_square[o]);}
}

for(o=0;o
{
if(allowed_square[o]%8==0)
{
if(allowed_square[o]!=64 && allowed_square[o]!=176)
{ return(allowed_square[o]);}
else if(allowed_square[o]==64 && Board[48]!=0)
{ return(allowed_square[o]);}
else if(allowed_square[o]==176 && Board[192]!=0)
{ return(allowed_square[o]);}
}
}

for(o=0;o
{
if(allowed_square[o]%8==7)
{
if(allowed_square[o]!=79 && allowed_square[o]!=191)
{ return(allowed_square[o]);}
else if(allowed_square[o]==79 && Board[63]!=0)
{ return(allowed_square[o]);}
else if(allowed_square[o]==191 && Board[207]!=0)
{ return(allowed_square[o]);}
}
}

for(o=0;o
{
if(allowed_square[o]<16)
{
if(allowed_square[o]!=4 && allowed_square[o]!=11)
{ return(allowed_square[o]);}
else if(allowed_square[o]==4 && Board[3]!=0)
{ return(allowed_square[o]);}
else if(allowed_square[o]==11 && Board[12]!=0)
{ return(allowed_square[o]);}
}
}

for(o=0;o
{
if(allowed_square[o]>240)
{
if(allowed_square[o]!=244 && allowed_square[o]!=251)
{ return(allowed_square[o]);}
else if(allowed_square[o]==244 && Board[243]!=0)
{ return(allowed_square[o]);}
else if(allowed_square[o]==251 && Board[252]!=0)
{ return(allowed_square[o]);}
}
}
if(stage<25)
for(o=0;o
{
if(allowed_square[o]==18)
{ return(allowed_square[o]);}
if(allowed_square[o]==33)
{ return(allowed_square[o]);}
if(allowed_square[o]==29)
{ return(allowed_square[o]);}
if(allowed_square[o]==46)
{ return(allowed_square[o]);}
if(allowed_square[o]==209)
{ return(allowed_square[o]);}
if(allowed_square[o]==226)
{ return(allowed_square[o]);}
if(allowed_square[o]==222)
{ return(allowed_square[o]);}
if(allowed_square[o]==237)
{ return(allowed_square[o]);}
}

for(o=0;o
{
if(allowed_square[o]==19 && Board[3]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==49 && Board[48]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==28 && Board[12]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==62 && Board[63]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==193 && Board[192]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==227 && Board[243]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==206 && Board[207]!=0)
{ return(allowed_square[o]);}
if(allowed_square[o]==236 && Board[252]!=0)
{ return(allowed_square[o]);}
}

for(o=0;o
{

if(allowed_square[o]==34||allowed_square[o]==45||allowed_square[o]==210||allowed_square[o]==221)
{ return(allowed_square[o]);}

}

for(o=0;o
{
if(allowed_square[o]==18 && Board[3]==0 &&
Board[33]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==33 && Board[48]==0 &&
Board[18]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==29 && Board[12]==0 &&
Board[46]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==46 && Board[63]==0 &&
Board[29]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==209 && Board[192]==0 &&
Board[226]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==226 && Board[243]==0 &&
Board[209]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==222 && Board[207]==0 &&
Board[237]!=Player_Color)
{ return(allowed_square[o]);}
if(allowed_square[o]==237 && Board[252]==0 &&
Board[222]!=Player_Color)
{ return(allowed_square[o]);}
}

for(o=0;o
{
store_sqr=allowed_square[o];

if(allowed_square[o]==18 && Board[3]==0) ;
else if(allowed_square[o]==33 && Board[48]==0) ;
else if(allowed_square[o]==29 && Board[12]==0) ;
else if(allowed_square[o]==46 && Board[63]==0) ;
else if(allowed_square[o]==209 && Board[192]==0) ;
else if(allowed_square[o]==226 && Board[243]==0) ;
else if(allowed_square[o]==222 && Board[207]==0) ;
else if(allowed_square[o]==237 && Board[252]==0) ;
else if(allowed_square[o]==64 || allowed_square[o]==176) ;
else if(allowed_square[o]==79 || allowed_square[o]==191) ;
else if(allowed_square[o]==4 || allowed_square[o]==11) ;
else if(allowed_square[o]==244 || allowed_square[o]==251) ;
else if(allowed_square[o]==19 && Board[3]==0) ;
else if(allowed_square[o]==49 && Board[48]==0) ;
else if(allowed_square[o]==28 && Board[12]==0) ;
else if(allowed_square[o]==62 && Board[63]==0) ;
else if(allowed_square[o]==193 && Board[192]==0) ;
else if(allowed_square[o]==227 && Board[243]==0) ;
else if(allowed_square[o]==206 && Board[207]==0) ;
else if(allowed_square[o]==236 && Board[252]==0) ;
else if(allowed_square[o]!=0)
{
Board[allowed_square[o]]=Computer_Color;
Marker(Player_Color);
flag=1;
for(int i=0;i<150;i++)
{

if(allowed_square[i]==3||allowed_square[i]==12||allowed_square[i]==48||allowed_square[i]==63||allowed_square[i]==192||allowed_square[i]==207||allowed_square[i]==243||allowed_square[i]==252)
flag=0;
}
allowed_square[o]=store_sqr;
Board[allowed_square[o]]=0;
Marker(Computer_Color);
Counter=store_c;
if(flag==1){
return(allowed_square[o]);}
}
}

for(o=0;o
{
store_sqr=allowed_square[o];

if(allowed_square[o]==18 && Board[3]==0) ;
else if(allowed_square[o]==33 && Board[48]==0) ;
else if(allowed_square[o]==29 && Board[12]==0) ;
else if(allowed_square[o]==46 && Board[63]==0) ;
else if(allowed_square[o]==209 && Board[192]==0) ;
else if(allowed_square[o]==226 && Board[243]==0) ;
else if(allowed_square[o]==222 && Board[207]==0) ;
else if(allowed_square[o]==237 && Board[252]==0) ;
else if(allowed_square[o]==64 || allowed_square[o]==176) ;
else if(allowed_square[o]==79 || allowed_square[o]==191) ;
else if(allowed_square[o]==4 || allowed_square[o]==11) ;
else if(allowed_square[o]==244 || allowed_square[o]==251) ;
else if(allowed_square[o]==19 && Board[3]==0) ;
else if(allowed_square[o]==49 && Board[48]==0) ;
else if(allowed_square[o]==28 && Board[12]==0) ;
else if(allowed_square[o]==62 && Board[63]==0) ;
else if(allowed_square[o]==193 && Board[192]==0) ;
else if(allowed_square[o]==227 && Board[243]==0) ;
else if(allowed_square[o]==206 && Board[207]==0) ;
else if(allowed_square[o]==236 && Board[252]==0) ;
else if(allowed_square[o]!=0)
{
return(allowed_square[o]);
}
}

randomize();
int mix=random(Counter);
for(o=0;o
{
if(o==mix)
if(allowed_square[o]!=0)
{
return(allowed_square[o]);
}
}
}


void Result_Declaration()
{
setcolor(6);
settextstyle(DEFAULT_FONT,0,1);
int c=0,p=0;

for(int o=0;o<256;o++)
{
if(Board[o]==Computer_Color)
c++;
if(Board[o]==Player_Color)
p++;
}
if(c>p)
outtextxy(x+200,y+0,"Computer Wins");
else if(p>c)
outtextxy(x+200,y+0,"Player Wins");
else if(c==p)
outtextxy(x+200,y+0,"Game Drawn");
}

void Write_Status_Game(int col)
{
setcolor(6);
settextstyle(DEFAULT_FONT,0,1);
outtextxy(x+190,y+180,"Computer");
outtextxy(x+190,y+200,"Player");
if(col==1)
{
setcolor(7);
outtextxy(x+260,y+180,"Black");
setcolor(2);
outtextxy(x+260,y+200,"Green");
}
else
{
setcolor(7);
outtextxy(x+260,y+200,"Black");
setcolor(2);
outtextxy(x+260,y+180,"Green");
}

}


void Marker(int turn)
{
int i;
for(i=0;i<150;i++)
{
allowed_square[i]=0;
source_square[i]=0;
movement_type[i]=0;
}
Counter=0;

if(turn==1)
for(i=0;i<256;i++)
{
if(Board[i]==1)
Check(i,1,2);
}
else if(turn==2)
for(i=0;i<256;i++)
{
if(Board[i]==2)
Check(i,2,1);
}
}

void Scorer()
{
int i;
int count_black=0,count_green=0;
for(i=0;i<256;i++)
{
if(Board[i]==1)
count_black++;
if(Board[i]==2)
count_green++;
}
gotoxy(74,7);

if(count_green<10)
cout" "br/>
else if(count_green<100)
cout" "br/>
else
cout""br/>

gotoxy(74,5);

if(count_black<10)
cout" "br/>
else if(count_black<100)
cout" "br/>
else
cout""br/>
}


void Draw_Allowed_Dots(int turn)
{

x=getmaxx()/2;
y=getmaxy()/2;

if(turn==1)
setcolor(0);
else if(turn==2)
setcolor(10);
else if(turn==0)//delete
setcolor(7);
for(int o=0;o<150;o++)
{
if(allowed_square[o]!=0)
{

circle(x-160+10+20*(allowed_square[o]%16),y-160+10+20*(allowed_square[o]/16),2);

circle(x-160+10+20*(allowed_square[o]%16),y-160+10+20*(allowed_square[o]/16),1);
}
}
}


void Convertor(int sqr,int turn)
{
int o,i;

for(o=0;o<150;o++)
{
if(allowed_square[o]==sqr)
{
i=source_square[o];
source_square[o]=allowed_square[o];
allowed_square[o]=i;

switch(movement_type[o])
{

case UP:

for(i=0;i<16;i++)
{
if( (allowed_square[o]-16*i)!=source_square[o])
{
Board[allowed_square[o]-16*i]=turn;
}
else
{
Board[allowed_square[o]-16*i]=turn;
break;
}
}
break;

case DOWN:

for(i=0;i<16;i++)
{
if( (allowed_square[o]+16*i)!=source_square[o])
{
Board[allowed_square[o]+16*i]=turn;
}
else
{
Board[allowed_square[o]+16*i]=turn;
break;
}
}
break;

case RIGHT:

for(i=0;i<16;i++)
{
if( (allowed_square[o]+1*i)!=source_square[o])
{
Board[allowed_square[o]+1*i]=turn;
}
else
{
Board[allowed_square[o]+1*i]=turn;
break;
}
}
break;

case LEFT:

for(i=0;i<16;i++)
{
if( (allowed_square[o]-1*i)!=source_square[o])
{
Board[allowed_square[o]-1*i]=turn;
}
else
{
Board[allowed_square[o]-1*i]=turn;
break;
}
}
break;

case RIGHT_UP:

for(i=0;i<16;i++)
{
if( (allowed_square[o]-15*i)!=source_square[o])
{
Board[allowed_square[o]-15*i]=turn;
}
else
{
Board[allowed_square[o]-15*i]=turn;
break;
}
}
break;

case RIGHT_DOWN:

for(i=0;i<16;i++)
{
if( (allowed_square[o]+17*i)!=source_square[o])
{
Board[allowed_square[o]+17*i]=turn;
}
else
{
Board[allowed_square[o]+17*i]=turn;
break;
}
}
break;

case LEFT_UP:

for(i=0;i<16;i++)
{
if( (allowed_square[o]-17*i)!=source_square[o])
{
Board[allowed_square[o]-17*i]=turn;
}
else
{
Board[allowed_square[o]-17*i]=turn;
break;
}
}
break;

case LEFT_DOWN:

for(i=0;i<16;i++)
{
if( (allowed_square[o]+15*i)!=source_square[o])
{
Board[allowed_square[o]+15*i]=turn;
}
else
{
Board[allowed_square[o]+15*i]=turn;
break;
}
}
break;
}
}
}

Board[119]=7;
Board[120]=7;
Board[135]=7;
Board[136]=7;
}



void Check(int sqr,int col1,int col2)
{
int i;

int qr=sqr;
int count_up=0,count_down=0,count_right=0,count_left=0;
int
count_right_up=0,count_right_down=0,count_left_up=0,count_left_down=0;

for(i=0;i<16;i++)
{

if(qr==48||qr==63||qr==29||qr==46||qr==33||qr==18||(qr<13&&qr>2))
{ break; }
qr-=16; count_up++;
}

qr=sqr;
for(i=0;i<16;i++)
{

if(qr==207||qr==192||qr==222||qr==209||qr==226||qr==237||(qr<253&&qr>242))
{ break; }
qr+=16; count_down++;
}

qr=sqr;
for(i=0;i<16;i++)
{
if(qr==12||qr==29||qr==46||qr==222||qr==252||qr==237||(qr+1)%16==0)
{ break; }
qr+=1; count_right++;
}
qr=sqr;
for(i=0;i<16;i++)
{
if(qr==3||qr==18||qr==33||qr==209||qr==226||qr==243||(qr)%16==0)
{ break; }
qr-=1; count_left++;
}

qr=sqr;
for(i=0;i<16;i++)
{

if(qr==49||qr==33||qr==18||qr==34||qr==19||(qr)%16==0||(qr<13&&qr>2))
{ break; }
qr-=17; count_left_up++;
}

qr=sqr;
for(i=0;i<16;i++)
{

if(qr==29||qr==28||qr==46||qr==45||qr==62||(qr+1)%16==0||(qr<13&&qr>2))
{ break; }
qr-=15; count_right_up++;
}

qr=sqr;
for(i=0;i<16;i++)
{

if(qr==206||qr==222||qr==221||qr==236||qr==237||(qr+1)%16==0||(qr<253&&qr>242))
{ break; }
qr+=17; count_right_down++;
}

qr=sqr;
for(i=0;i<16;i++)
{

if(qr==209||qr==210||qr==226||qr==227||qr==193||(qr)%16==0||(qr<253&&qr>242))
{ break; }
qr+=15; count_left_down++;
}


int up_move=0;
qr=sqr;

for(i=0;i
{
qr-=16;

if(Board[qr]==col2)
{up_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(up_move==1)
{
up_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=UP;
Counter++;
}
break; }


if(qr==48||qr==63||qr==29||qr==46||qr==33||qr==18||(qr<13&&qr>2))
{ break; }

}

int down_move=0;
qr=sqr;

for(i=0;i
{
qr+=16;

if(Board[qr]==col2)
{down_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(down_move==1)
{
down_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=DOWN;
Counter++;
}
break; }


if(qr==207||qr==192||qr==222||qr==209||qr==226||qr==237||(qr<253&&qr>242))
{ break; }

}


int right_move=0;
qr=sqr;

for(i=0;i
{
qr+=1;

if(Board[qr]==col2)
{right_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(right_move==1)
{
right_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=RIGHT;
Counter++;
}
break; }

if(qr==12||qr==29||qr==46||qr==222||qr==252||qr==237||(qr+1)%16==0)
{ break; }

}
int left_move=0;
qr=sqr;

for(i=0;i
{
qr-=1;

if(Board[qr]==col2)
{left_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(left_move==1)
{
left_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=LEFT;
Counter++;
}
break; }

if(qr==3||qr==18||qr==33||qr==209||qr==226||qr==243||(qr)%16==0)
{ break; }

}

int left_up_move=0;
qr=sqr;

for(i=0;i
{
qr-=17;

if(Board[qr]==col2)
{left_up_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(left_up_move==1)
{
left_up_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=LEFT_UP;
Counter++;
}
break; }


if(qr==49||qr==33||qr==18||qr==34||qr==19||(qr)%16==0||(qr<13&&qr>2))
{ break; }

}


int left_down_move=0;
qr=sqr;

for(i=0;i
{
qr+=15;

if(Board[qr]==col2)
{left_down_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(left_down_move==1)
{
left_down_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=LEFT_DOWN;
Counter++;
}
break; }


if(qr==209||qr==210||qr==226||qr==227||qr==193||(qr)%16==0||(qr<253&&qr>242))
{ break; }

}

int right_down_move=0;
qr=sqr;

for(i=0;i
{
qr+=17;

if(Board[qr]==col2)
{right_down_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(right_down_move==1)
{
right_down_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=RIGHT_DOWN;
Counter++;
}
break; }


if(qr==206||qr==222||qr==221||qr==236||qr==237||(qr+1)%16==0||(qr<253&&qr>242))
{ break; }

}

int right_up_move=0;
qr=sqr;

for(i=0;i
{
qr-=15;

if(Board[qr]==col2)
{right_up_move=1;}
else if(Board[qr]==7)
{}
else if(Board[qr]==col1)
{break; }
else if(Board[qr]==0)
{
if(right_up_move==1)
{
right_up_move=qr;
allowed_square[Counter]=qr;
source_square[Counter]=sqr;
movement_type[Counter]=RIGHT_UP;
Counter++;
}
break; }


if(qr==29||qr==28||qr==46||qr==45||qr==62||(qr+1)%16==0||(qr<13&&qr>2))
{ break; }

}
}


void Screen()
{
x=getmaxx()/2;
y=getmaxy()/2;

int i,o;
setlinestyle(SOLID_LINE,0,2);
setcolor(8);

for(i=0;i<17;i++)
{
line(x-160,y-160+i*20,x+160,y-160+i*20);
line(x-160+i*20,y+160,x-160+i*20,y-160);
}
setlinestyle(SOLID_LINE,0,1);

for(o=0;o<256;o++)
{
if(Board[o]==9)
{
setfillstyle(SOLID_FILL,8);
floodfill(x-160+10+20*(o%16),y-160+10+20*(o/16),8);
}
if(Board[o]==7)
{
setfillstyle(SOLID_FILL,4);
floodfill(x-160+10+20*(o%16),y-160+10+20*(o/16),8);
}
if(Board[o]==1)
{
setfillstyle(SOLID_FILL,0);
floodfill(x-160+10+20*(o%16),y-160+10+20*(o/16),8);
}
if(Board[o]==2)
{
setfillstyle(SOLID_FILL,10);
floodfill(x-160+10+20*(o%16),y-160+10+20*(o/16),8);
}
}
setcolor(6);
circle(x,y+200,10);
setfillstyle(SOLID_FILL,6);
floodfill(x,y+200,6);
setcolor(14);
line(x-4,y-4+200,x+4,y+4+200);
line(x+4,y-4+200,x-4,y+4+200);

setcolor(8);
rectangle(x-180,y-180,x+180,y+180);
setfillstyle(SOLID_FILL,8);
floodfill(x-170,y,8);
setcolor(0);
line(x-180,y-120,x-120,y-180);
line(x+180,y-120,x+120,y-180);
line(x-180,y+120,x-120,y+180);
line(x+180,y+120,x+120,y+180);
setfillstyle(SOLID_FILL,0);
floodfill(x-175,y-175,0);
floodfill(x+175,y-175,0);
floodfill(x+175,y+175,0);
floodfill(x-175,y+175,0);


settextstyle(3,0,1);
setcolor(1);
outtextxy(x+200,y-182,"BLACK");
setcolor(2);
outtextxy(x+200,y-151,"GREEN");

}

void Press_Exit_Button()
{
setcolor(14);
circle(x,y+200,10);
setfillstyle(SOLID_FILL,14);
floodfill(x,y+202,14);
setcolor(6);
line(x-4,y-4+200,x+4,y+4+200);
line(x+4,y-4+200,x-4,y+4+200);
delay(500);
setcolor(6);
circle(x,y+200,10);
setfillstyle(SOLID_FILL,6);
floodfill(x,y+205,6);
setcolor(14);
line(x-4,y-4+200,x+4,y+4+200);
line(x+4,y-4+200,x-4,y+4+200);
delay(500);
}


int Ask_Mouse(int mx,int my)
{
int Square=1000;
int xx=50,yy=50;

if(mx>=x-160&&mx else
if(mx>=x-140&&mx
else if(mx>=x-120&&mx
else if(mx>=x-100&&mx
else if(mx>=x-80&&mx
else if(mx>=x-60&&mx
else if(mx>=x-40&&mx
else if(mx>=x-20&&mx else if(mx>=x
&&mx else
if(mx>=x+20&&mx
else if(mx>=x+40&&mx
else if(mx>=x+60&&mx
else if(mx>=x+80&&mx
else if(mx>=x+100&&mx else if(mx>=x+120&&mx else if(mx>=x+140&&mx
if(my>=y-160&&my else
if(my>=y-140&&my
else if(my>=y-120&&my
else if(my>=y-100&&my
else if(my>=y-80&&my
else if(my>=y-60&&my
else if(my>=y-40&&my
else if(my>=y-20&&my else if(my>=y
&&my else
if(my>=y+20&&my
else if(my>=y+40&&my
else if(my>=y+60&&my
else if(my>=y+80&&my
else if(my>=y+100&&my else if(my>=y+120&&my else if(my>=y+140&&my
if(xx!=50&&yy!=50)
{
Square=16*yy+xx;
return Square;
}


if(mx>=x-10&&mx=y+190&&my
return 555;
if(mx>=x-260&&mx=y+195&&my
return 333;

return 1;
}

void Reset()
{
int i;
for(i=0;i<256;i++) Board[i]=0;
for(i=0;i<3;i++) Board[i]=9;
for(i=13;i<18;i++) Board[i]=9;
for(i=30;i<33;i++) Board[i]=9;

Board[47]=9; Board[208]=9;

for(i=223;i<226;i++) Board[i]=9;
for(i=238;i<243;i++) Board[i]=9;
for(i=253;i<256;i++) Board[i]=9;

Board[103]=1; Board[104]=2;
Board[119]=7; Board[120]=7;
Board[135]=7; Board[136]=7;
Board[151]=2; Board[152]=1;

for(i=0;i<150;i++)
{
allowed_square[i]=0;
source_square[i]=0;
movement_type[i]=0;
}
cleardevice();
}

void Welcome()
{
setcolor(LIGHTBLUE);
settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
outtextxy(x-100,y-210,"TRYSTER");
setcolor(BLUE);
settextstyle(3,HORIZ_DIR,3);
setcolor(YELLOW);
outtextxy(x-40,y+130,"Creator");
setcolor(RED);
outtextxy(x-255,y+180," Suneet Singh 99/CSE/123 CRSCE Murthal");

setcolor(6);
outtextxy(x-105,y-60,"'First Prize Winner'");
outtextxy(x-225,y-10,"N-CODE Predefined Software Competition.");
outtextxy(x-125,y+50,"TRYST 2002, IIT-Delhi");

setcolor(GREEN);
outtextxy(x-255,y+180," - - ");
sleep(1);
getch();
cleardevice();
}

void Who_Play_First()
{
setcolor(4);
settextstyle(DEFAULT_FONT,0,2);
outtextxy(x-115,y-20,"Who plays first ");
outtextxy(x-135,y+20,"Player Computer");
setcolor(14);
outtextxy(x-135,y+20,"P C");

settextstyle(4,0,4);
setcolor(6);
outtextxy(x-70,y-232,"TRYSTER");
settextstyle(DEFAULT_FONT,0,2);

while(1)
{
if(kbhit())
{
ii.h.ah=0;
int86(22,&ii,&oo);
if(oo.h.ah==25)
{
Whoplays_first=PLAYER;
setcolor(4);
outtextxy(x-135,y+20,"P");
delay(400);
setcolor(14);
outtextxy(x-135,y+20,"P");
delay(400);
break;
}
if(oo.h.ah==46)
{
Whoplays_first=COMPUTER;
setcolor(4);
outtextxy(x-135,y+20," C");
delay(400);
setcolor(14);
outtextxy(x-135,y+20," C");
delay(400);
break;
}
}

}
setfillstyle(SOLID_FILL,7);
bar(x-180,y-180,x+180,y+180);
}

void Color_Allotment()
{
if(Whoplays_first==PLAYER)
{
settextstyle(DEFAULT_FONT,0,1);
setcolor(4);
outtextxy(x+190,y+20,"Choose Color...");
outtextxy(x+190,y+50,"Click on the DOT");

while(1)
{
getmousepos(&button,&mousex,&mousey);

if((button&1)==1)
{

hidemouseptr();

while((button&1)==1)
{
getmousepos(&button,&mousex,&mousey);
mousetrap=1;
}
getmousepos(&button,&mousex,&mousey);
reply=Ask_Mouse(mousex,mousey);
if(reply==87||reply==102||reply==153||reply==168)
{
Marker(2);
Draw_Allowed_Dots(0);
Marker(1);
Draw_Allowed_Dots(0);
turn =2;
Computer_Color=1;
Player_Color=2;
break;
}
else if(reply==88||reply==105||reply==150||reply==167)
{
Marker(2);
Draw_Allowed_Dots(0);
Marker(1);
Draw_Allowed_Dots(0);
turn =1;
Computer_Color=2;
Player_Color=1;
break;
}
mousetrap=0;
showmouseptr();
}

}

settextstyle(DEFAULT_FONT,0,1);
setcolor(0);
outtextxy(x+190,y+20,"Choose Color...");
outtextxy(x+190,y+50,"Click on the DOT");
}
else if(Whoplays_first==COMPUTER)
{
settextstyle(DEFAULT_FONT,0,1);
setcolor(4);
outtextxy(x+190,y+20,"Computer'S Color");
outtextxy(x+190,y+50,"Green Black");
setcolor(14);
outtextxy(x+190,y+50,"G B");

while(1){
if(kbhit())
{
ii.h.ah=0;
int86(22,&ii,&oo);
if(oo.h.ah==34)
{
setcolor(4);
outtextxy(x+190,y+50,"G");
delay(400);
setcolor(14);
outtextxy(x+190,y+50,"G");
delay(400);
turn=2;
Computer_Color=2;
Player_Color=1;
break;
}
if(oo.h.ah==48)
{
setcolor(4);
outtextxy(x+278,y+50,"B");
delay(400);
setcolor(14);
outtextxy(x+278,y+50,"B");
delay(400);
turn=1;
Computer_Color=1;
Player_Color=2;
break;
}
}
}

settextstyle(DEFAULT_FONT,0,1);
setcolor(0);
outtextxy(x+190,y+20,"Computer'S Color");
outtextxy(x+190,y+50,"Green Black");
Marker(2);
Draw_Allowed_Dots(0);
Marker(1);
Draw_Allowed_Dots(0);
}
}



Links
to this post



|













0

Four tips for speaking from a podium

Posted by virtualinfocom

on

3:30 PM

Here are four tips for making your next speech from the podium hum with confidence:
1. Keep your feet planted and stand up straight. This will convey poise
and strength, even if that's not what you're feeling.
2. Don't memorize. Unless the speech is very short, the anxiety of
trying to remember your lines will only make your task harder.
3. Find a place for your hands. Put your hands in one place - for
example, on the sides of the podium - and then forget about them. You
will bring them up naturally to gesture as long as they have a place to
return to.
4. Practice, practice, practice. Rehearse as many times as you can, in
an environment as close to the real experience as possible."



Links
to this post



|














0

Source code for Tetris Game

Posted by virtualinfocom

on

1:21 PM



#include
#include
#include
#include
#include
#include

#define UNOCCUPIED 0
#define OCCUPIED 1

#define YES 1
#define NO 0

#define NORMAL 3
#define SKIP 2
#define DRAW 1
#define DEL 0

#define FIXED 1
#define FALLING 0



int Checker1(int);
int Checker2(int);
int Checker3(int);
int Checker4(int);
int Checker5(int);
int Checker6(int);
int Checker7(int);

int Block_Setter(int,int,int,int,int);
void Draw_Screen();
void Show_Next_Block(int);
void Initialize();
void Write_Status();
void Present_Block_Setter();

int Column[352],Row[352];
int Status_Cell[22][16];
int Score=0;
int
Count_Block_1=0,Count_Block_2=0,Count_Block_3=0,Count_Block_4=0,Count_Block_5=0,Count_Block_6=0,Count_Block_7=0;
int Room1,Room2,Room3,Room4,level1,level2,level3,level4;
int Block_Type,Rotation_Number=0;
int Counter,Time,Color,Speed_Decelarator=5;
int Present_Block,Next_Block;

void main()
{

int d=DETECT,m;
initgraph(&d,&m,"c:\\tc\\bgi");

int x,y;
x=getmaxx()/2;
y=getmaxy()/2;

union REGS ii,oo;
int loop,num;
int allow_shift=1;
int go=1;
int freefall=0;
int status=0;

Initialize();
randomize();
Next_Block=random(7);
Draw_Screen();


for(Counter=500;Counter>=100;Counter-=Speed_Decelarator)
{

if(Counter<=400) Speed_Decelarator=4;
if(Counter<=300) Speed_Decelarator=3;
if(Counter<=200) Speed_Decelarator=1;
if(Counter<=100) Counter=102;

Write_Status();

Present_Block=Next_Block;

Next_Block=random(7);

Show_Next_Block(Next_Block);

Present_Block_Setter();

status=0;
Rotation_Number=0;

while(loop==YES)
{

status=Block_Setter(level1,Room1,DRAW,Color,0);
if(status==FIXED)
loop=NO;
status=Block_Setter(level2,Room2,DRAW,Color,0);
if(status==FIXED)
loop=NO;
status=Block_Setter(level3,Room3,DRAW,Color,0);
if(status==FIXED)
loop=NO;
status=Block_Setter(level4,Room4,DRAW,Color,0);
if(status==FIXED)
loop=NO;


if(freefall==0)
Time=Counter;
else if(freefall==1)
Time=0;

if(loop==YES)
delay(Time);


if(level1<22&&level2<22&&level3<22&&level4<22&&loop==YES)
{
status=Block_Setter(level1,Room1,DEL,Color,0);
status=Block_Setter(level2,Room2,DEL,Color,0);
status=Block_Setter(level3,Room3,DEL,Color,0);
status=Block_Setter(level4,Room4,DEL,Color,0);

if(loop==YES)
{
level1++;
level2++;
level3++;
level4++;
}
}
else
{
loop=NO;
}

if(kbhit()&&loop==YES)
{
ii.h.ah=0;
int86(22,&ii,&oo);
go=1;
if(oo.h.ah==1)
{
closegraph();
exit(0);
}
if(oo.h.ah==77)
{
for(num=351;num>=0;num--)
{
if(Checker1(num))
allow_shift=NO;
}

if(Room1<16&&Room2<16&&Room3<16&&Room4<16&&allow_shift==YES)
{
Room1++;Room2++;Room3++;Room4++;
}
allow_shift=YES;
}
if(oo.h.ah==75)
{
for(num=351;num>=0;num--)
{
if(Checker2(num))
allow_shift=NO;
}

if(Room1>1&&Room2>1&&Room3>1&&Room4>1&&allow_shift==YES)
{
Room1--;Room2--;Room3--;Room4--;
}
allow_shift=YES;
}
if(oo.h.ah==72)
{
if(Block_Type==2)
for(num=351;num>=0;num--)
{
if(Checker3(num))
go=0;
if(Checker4(num))
go=0;
}
else
for(num=351;num>=0;num--)
{
if(Checker5(num))
go=0;
if(Checker6(num))
go=0;
}

if(Room1<16&&Room2<16&&Room3<16&&Room4<16&&Room1>1&&Room2>1&&Room3>1&&Room4>1&&level1<22&&level2<22&&level3<22&&level4<22&&go==1)
{
if(Rotation_Number==0)
switch(Block_Type)
{
case 1:break;
case 2:
{Room1--;Room3++;Room4+=2;level1++;level3--;level4-=2;}break;
case 3:
{Room1+=2;level1++;level3++;}break;
case 4:
{Room2-=2;level2++;level4++;}break;
case 5: {Room1++;level1--;}break;
case 6:
{Room2++;Room3--;level3-=2;}break;
case 7:
{Room2--;Room3++;level3-=2;}break;
}
else if(Rotation_Number==1)
switch(Block_Type)
{
case 1:break;
case 2:
{Room1++;Room3--;Room4-=2;level1--;level3++;level4+=2;}break;
case 3:
{Room1-=2;level1--;level3--;}break;
case 4:
{Room2+=2;level2--;level4--;}break;
case 5: {Room4--;level4--;}break;
case 6:
{Room1++;Room3++;level1++;level3++;level2--;level4--;}break;
case 7:
{Room3-=2;level1++;level3--;}break;
}
else if(Rotation_Number==2)
switch(Block_Type)
{
case 1:break;
case
2:Room1--;Room3++;Room4+=2;level1++;level3--;level4-=2;break;
case 3:Room1+=2;level1++;level3++;break;
case 4:Room2-=2;level2++;level4++;break;
case 5:Room3--;level3++;break;
case 6:Room2--;Room4++;level4+=2;break;
case 7:Room4++;Room3--;level3+=2;break;
}
else if(Rotation_Number==3)
switch(Block_Type)
{
case 1:break;
case
2:Room1++;Room3--;Room4-=2;level1--;level3++;level4+=2;break;
case 3:Room1-=2;level1--;level3--;break;
case 4:Room2+=2;level2--;level4--;break;
case
5:Room1--;Room3++;Room4++;level1++;level3--;level4++;break;
case
6:Room1--;Room4--;level1--;level2++;level3++;level4--;break;
case
7:Room2++;Room3+=2;Room4--;level1--;level3++;break;
}

Rotation_Number++;
if(Rotation_Number==4) Rotation_Number=0;
}
}
if(oo.h.ah==80)
{
freefall=1;
}
if(oo.h.ah==28)
{
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setcolor(15);
outtextxy(x-20,y-10,"Paused");
getch();
setcolor(0);
outtextxy(x-20,y-10,"Paused");
}
}


if(loop==NO)
{
Block_Setter(level1,Room1,SKIP,Color,0);
Block_Setter(level2,Room2,SKIP,Color,0);
Block_Setter(level3,Room3,SKIP,Color,0);
Block_Setter(level4,Room4,SKIP,Color,0);
Block_Setter(level1,Room1,NORMAL,Color,0);
Block_Setter(level2,Room2,NORMAL,Color,0);
Block_Setter(level3,Room3,NORMAL,Color,0);
Block_Setter(level4,Room4,NORMAL,Color,1);
freefall=0;
}
}
loop=YES;
}

}

int Block_Setter(int level,int Room,int col,int b_Color,int check)
{
int num_fix=0,return_1=NO;
int x,y;
int num;
int skip=NO;

x=getmaxx()/2;
y=getmaxy()/2;

if(col==SKIP)
{
col=1;
skip=YES;
}

if(skip==NO)
{
for(num=351;num>=0;num--)
if(level==Column[num]-1&&Room==Row[num])
{
if(level<=1)
{
setcolor(14);
settextstyle(3,0,1);
bar(x-55,y-25,x+55,y+10);
outtextxy(x-47,y-20,"Game Over");
getch();
sleep(1);
closegraph();
exit(0);
}
col=NORMAL;
}
}

if(col==DRAW)
{
setfillstyle(SOLID_FILL,b_Color);

bar(x-160+1+20*(Room-1),y-220+1+20*(level-1),x-140-1+20*(Room-1),y-200-1+20*(level-1));
}
else if(col==DEL)
{
setfillstyle(SOLID_FILL,0);

bar(x-160+1+20*(Room-1),y-220+1+20*(level-1),x-140-1+20*(Room-1),y-200-1+20*(level-1));
}
else
{
Status_Cell[level-1][Room-1]=OCCUPIED;
int repeat=1;
while(repeat==1)
{
repeat=0;
if(Column[num_fix]==0&&Row[num_fix]==0)
{
Column[num_fix]=level;
Row[num_fix]=Room;
}
else
{
num_fix++;
repeat=1;
}
}
if(num_fix==351) num_fix=0;
else num_fix++;

sound(200); delay(30); nosound();

return_1=YES;
}

int comp[22];
int checkagain=1;
int loop1,loop2;

while(checkagain==1)
{
checkagain=0;
if(check==1)
{

for(loop1=0;loop1<22;loop1++)
comp[loop1]=1;

for(loop1=0;loop1<22;loop1++)
for(loop2=0;loop2<16;loop2++)
if(Status_Cell[loop1][loop2]==UNOCCUPIED)
comp[loop1]=0;

for(loop1=21;loop1>=0;loop1--)
if(comp[loop1]==1)
{
for(num=351;num>=0;num--)
if(Column[num]==loop1+1)
{
Column[num]=0;Row[num]=0;
}
for(num=351;num>=0;num--)
if(Column[num]<=loop1&&Column[num]!=0)
{
Column[num]++;
}
for(loop2=loop1;loop2>0;loop2--)
for(num=0;num<16;num++)
{
Status_Cell[loop2][num]=Status_Cell[loop2-1][num];
}
for(num=0;num<16;num++)
Status_Cell[0][num]=UNOCCUPIED;

setfillstyle(SOLID_FILL,0);
bar(x-160,y-220,x+160,y+220);
setcolor(WHITE);
rectangle(x-161,y-221,x+161,y+221);
rectangle(x-163,y-223,x+163,y+223);
setfillstyle(SOLID_FILL,0);

for(num=0;num<16;num++)

bar(x-160+1+20*(num),y-220+1+20*(loop1),x-140-1+20*(num),y-200-1+20*(loop1));
setfillstyle(SOLID_FILL,LIGHTRED);

for(loop2=21;loop2>=0;loop2--)
{
for(num=0;num<16;num++)
if(Status_Cell[loop2][num]==OCCUPIED)

bar(x-160+1+20*(num),y-220+1+20*(loop2),x-140-1+20*(num),y-200-1+20*(loop2));
}
checkagain=1;
loop1=-1;
Score++;
}
}
}

if(return_1==YES)
return FIXED;
else
return FALLING;
}

void Draw_Screen()
{
int x,y;
x=getmaxx()/2;
y=getmaxy()/2;

setcolor(WHITE);
rectangle(x-161,y-221,x+161,y+221);
rectangle(x-163,y-223,x+163,y+223);

setfillstyle(11,8);
floodfill(x-290,y+220,WHITE);
setfillstyle(SOLID_FILL,BLUE);
bar(x+210+1,y-220+1,x+230-1,y-200-1);
bar(x+190+1,y-220+1,x+210-1,y-200-1);
bar(x+210+1,y-200+1,x+230-1,y-180-1);
bar(x+190+1,y-200+1,x+210-1,y-180-1);
setfillstyle(SOLID_FILL,GREEN);
bar(x+210+1,y-160+1,x+230-1,y-140-1);
bar(x+230+1,y-160+1,x+250-1,y-140-1);
bar(x+190+1,y-160+1,x+210-1,y-140-1);
bar(x+170+1,y-160+1,x+190-1,y-140-1);
setfillstyle(SOLID_FILL,RED);
bar(x+210+1,y-75+1,x+230-1,y-55-1);
bar(x+210+1,y-55+1,x+230-1,y-35-1);
bar(x+190+1,y-35+1,x+210-1,y-15-1);
bar(x+190+1,y-55+1,x+210-1,y-35-1);
setfillstyle(SOLID_FILL,7);
bar(x+200+1,y-5+1,x+220-1,y+15-1);
bar(x+200+1,y+15+1,x+220-1,y+35-1);
bar(x+220+1,y-5+1,x+240-1,y+15-1);
bar(x+180+1,y-5+1,x+200-1,y+15-1);
setfillstyle(SOLID_FILL,BROWN);
bar(x+200+1,y+45+1,x+220-1,y+65-1);
bar(x+220+1,y+65+1,x+240-1,y+85-1);
bar(x+220+1,y+45+1,x+240-1,y+65-1);
bar(x+180+1,y+45+1,x+200-1,y+65-1);
setfillstyle(SOLID_FILL,MAGENTA);
bar(x+200+1,y-110+1,x+220-1,y-90-1);
bar(x+220+1,y-130+1,x+240-1,y-110-1);
bar(x+220+1,y-110+1,x+240-1,y-90-1);
bar(x+180+1,y-110+1,x+200-1,y-90-1);
setfillstyle(SOLID_FILL,CYAN);
bar(x+190+1,y+100+1,x+210-1,y+120-1);
bar(x+210+1,y+100+1,x+230-1,y+120-1);
bar(x+210+1,y+120+1,x+230-1,y+140-1);
bar(x+190+1,y+80+1,x+210-1,y+100-1);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
outtextxy(x+190,y+205,"STATISTICS");

setlinestyle(SOLID_LINE,1,3);
line(x-285,y+120,x-285,y+135);
line(x-285,y+120,x-290,y+125);
line(x-285,y+120,x-280,y+125);
line(x-285,y+185,x-285,y+200);
line(x-285,y+200,x-290,y+195);
line(x-285,y+200,x-280,y+195);
line(x-292,y+150,x-278,y+150);
line(x-292,y+150,x-287,y+155);
line(x-292,y+150,x-287,y+145);
line(x-292,y+170,x-278,y+170);
line(x-278,y+170,x-283,y+175);
line(x-278,y+170,x-283,y+165);
setlinestyle(SOLID_LINE,1,1);
setcolor(BROWN);
line(x-265,y+170,x-260,y+170);
line(x-265,y+190,x-260,y+190);
line(x-265,y+150,x-260,y+150);
line(x-265,y+128,x-260,y+128);
line(x-255,y+217,x-250,y+217);
outtextxy(x-292,y+205,"ESC");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(x-240,y+215,"Exit");
setcolor(BLUE);
outtextxy(x-285,y-70,"Enter");
outtextxy(x-230,y-70,"Pause");
setcolor(5);
line(x-243,y-67,x-237,y-67);
setcolor(RED);
outtextxy(x-250,y+125,"Rotate");
outtextxy(x-250,y+146,"Move left");
outtextxy(x-250,y+188,"Free fall");
outtextxy(x-250,y+166,"Move right");


setcolor(GREEN);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
outtextxy(x-263,y+55,"NEXT");
setcolor(WHITE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(x-300,y-215,"LINES __");

}

void Show_Next_Block(int Block)
{

int x,y;
x=getmaxx()/2;
y=getmaxy()/2;

int shift_x=-450;

setfillstyle(SOLID_FILL,BLACK);
bar(x-290+1,y-50,x-191,y+50);
setcolor(WHITE);
rectangle(x-290+1,y-50,x-191,y+50);

switch(Block)
{
case 0:
setfillstyle(SOLID_FILL,BLUE);
bar(x+210+1+shift_x,y-220+1+200,x+230-1+shift_x,y-200-1+200);
bar(x+190+1+shift_x,y-220+1+200,x+210-1+shift_x,y-200-1+200);
bar(x+210+1+shift_x,y-200+1+200,x+230-1+shift_x,y-180-1+200);
bar(x+190+1+shift_x,y-200+1+200,x+210-1+shift_x,y-180-1+200);
break;
case 1:
setfillstyle(SOLID_FILL,GREEN);
bar(x+210+1+shift_x,y-160+1+150,x+230-1+shift_x,y-140-1+150);
bar(x+230+1+shift_x,y-160+1+150,x+250-1+shift_x,y-140-1+150);
bar(x+190+1+shift_x,y-160+1+150,x+210-1+shift_x,y-140-1+150);
bar(x+170+1+shift_x,y-160+1+150,x+190-1+shift_x,y-140-1+150);
break;
case 2:
setfillstyle(SOLID_FILL,CYAN);

bar(x+190+1+shift_x,y+110+1-10-110,x+210-1+shift_x,y+130-1-10-110);

bar(x+210+1+shift_x,y+110+1-10-110,x+230-1+shift_x,y+130-1-10-110);

bar(x+210+1+shift_x,y+130+1-10-110,x+230-1+shift_x,y+150-1-10-110);

bar(x+190+1+shift_x,y+90+1-10-110,x+210-1+shift_x,y+110-1-10-110);
break;
case 3:
setfillstyle(SOLID_FILL,RED);
bar(x+210+1+shift_x,y-60+1-15+45,x+230-1+shift_x,y-40-1-15+45);
bar(x+210+1+shift_x,y-40+1-15+45,x+230-1+shift_x,y-20-1-15+45);
bar(x+190+1+shift_x,y-20+1-15+45,x+210-1+shift_x,y-0-1-15+45);
bar(x+190+1+shift_x,y-40+1-15+45,x+210-1+shift_x,y-20-1-15+45);
break;
case 4:
setfillstyle(SOLID_FILL,7);
bar(x+200+1+shift_x,y+10+1-15-5,x+220-1+shift_x,y+30-1-15-5);
bar(x+200+1+shift_x,y+30+1-15-5,x+220-1+shift_x,y+50-1-15-5);
bar(x+220+1+shift_x,y+10+1-15-5,x+240-1+shift_x,y+30-1-15-5);
bar(x+180+1+shift_x,y+10+1-15-5,x+200-1+shift_x,y+30-1-15-5);
break;
case 5:
setfillstyle(SOLID_FILL,BROWN);
bar(x+200+1+shift_x,y+60+1-15-55,x+220-1+shift_x,y+80-1-15-55);
bar(x+220+1+shift_x,y+80+1-15-55,x+240-1+shift_x,y+100-1-15-55);
bar(x+220+1+shift_x,y+60+1-15-55,x+240-1+shift_x,y+80-1-15-55);
bar(x+180+1+shift_x,y+60+1-15-55,x+200-1+shift_x,y+80-1-15-55);
break;
case 6:
setfillstyle(SOLID_FILL,MAGENTA);
bar(x+200+1+shift_x,y-110+1+105,x+220-1+shift_x,y-90-1+105);
bar(x+220+1+shift_x,y-130+1+105,x+240-1+shift_x,y-110-1+105);
bar(x+220+1+shift_x,y-110+1+105,x+240-1+shift_x,y-90-1+105);
bar(x+180+1+shift_x,y-110+1+105,x+200-1+shift_x,y-90-1+105);
break;
default:
break;
}
}

void Write_Status()
{
gotoxy(15,3); coutbr/>
gotoxy(75,3); coutbr/>
gotoxy(75,6); coutbr/>
gotoxy(75,9); coutbr/>
gotoxy(75,13); coutbr/>
gotoxy(75,16); coutbr/>
gotoxy(75,19); coutbr/>
gotoxy(75,23); coutbr/>
}

void Present_Block_Setter()
{
switch(Present_Block)
{
case 0:
Count_Block_1++;
Block_Type=1;
Room1=8;Room2=9;Room3=8;Room4=9;
level1=1;level2=1;level3=2;level4=2;
Color=1;
break;
case 1:
Count_Block_2++;
Block_Type=2;
Room1=8;Room2=8;Room3=8;Room4=8;
level1=1;level2=2;level3=3;level4=4;
Color=2;
break;
case 2:
Count_Block_3++;
Block_Type=3;
Room1=8;Room2=9;Room3=8;Room4=9;
level1=1;level2=2;level3=2;level4=3;
Color=3;
break;
case 3:
Count_Block_4++;
Block_Type=4;
Room1=8;Room2=9;Room3=8;Room4=9;
level1=2;level2=1;level3=3;level4=2;
Color=4;
break;
case 4:
Count_Block_5++;
Block_Type=5;
Room1=8;Room2=9;Room3=10;Room4=9;
level1=1;level2=1;level3=1;level4=2;
Color=7;
break;
case 5:
Count_Block_6++;
Block_Type=6;
Room1=8;Room2=8;Room3=8;Room4=9;
level1=1;level2=2;level3=3;level4=1;
Color=6;
break;
case 6:
Count_Block_7++;
Block_Type=7;
Room1=8;Room2=8;Room3=8;Room4=7;
level1=1;level2=2;level3=3;level4=1;
Color=5;
break;
}
}


void Initialize()
{

for(int q=0;q<22;q++)
for(int q1=0;q1<16;q1++)
Status_Cell[q][q1]=UNOCCUPIED;

for(q=0;q<351;q++)
{
Column[q]=0;
Row[q]=0;
}

}
int Checker1(int num)
{
if(level1==Column[num]-1&&Room1+1==Row[num]||level2==Column[num]-1&&Room2+1==Row[num]||level3==Column[num]-1&&Room3+1==Row[num]||level4==Column[num]-1&&Room4+1==Row[num]||level1==Column[num]&&Room1+1==Row[num]||level2==Column[num]&&Room2+1==Row[num]||level3==Column[num]&&Room3+1==Row[num]||level4==Column[num]&&Room4+1==Row[num])
return 1;
else
return 0;

}

int Checker2(int num)
{
if(level1==Column[num]-1&&Room1-1==Row[num]||level2==Column[num]-1&&Room2-1==Row[num]||level3==Column[num]-1&&Room3-1==Row[num]||level4==Column[num]-1&&Room4-1==Row[num]||level1==Column[num]&&Room1-1==Row[num]||level2==Column[num]&&Room2-1==Row[num]||level3==Column[num]&&Room3-1==Row[num]||level4==Column[num]&&Room4-1==Row[num])
return 1;
else
return 0;
}

int Checker3(int num)
{
if(level1==Column[num]-1&&Room1+1==Row[num]||level2==Column[num]-1&&Room2+1==Row[num]||level3==Column[num]-1&&Room3+1==Row[num]||level4==Column[num]-1&&Room4+1==Row[num]||level1==Column[num]&&Room1+1==Row[num]||level2==Column[num]&&Room2+1==Row[num]||level3==Column[num]&&Room3+1==Row[num]||level4==Column[num]&&Room4+1==Row[num]&&level1==Column[num]-2&&Room1+1==Row[num]||level2==Column[num]-2&&Room2+1==Row[num]||level3==Column[num]-2&&Room3+1==Row[num]||level4==Column[num]-2&&Room4+1==Row[num]||level1==Column[num]&&Room1+1==Row[num]||level2==Column[num]&&Room2+1==Row[num]||level3==Column[num]&&Room3+1==Row[num]||level4==Column[num]&&Room4+1==Row[num])
return 1;
else
return 0;
}


int Checker4(int num)
{
if(level1==Column[num]-1&&Room1-1==Row[num]||level2==Column[num]-1&&Room2-1==Row[num]||level3==Column[num]-1&&Room3-1==Row[num]||level4==Column[num]-1&&Room4-1==Row[num]||level1==Column[num]&&Room1-1==Row[num]||level2==Column[num]&&Room2-1==Row[num]||level3==Column[num]&&Room3-1==Row[num]||level4==Column[num]&&Room4-1==Row[num]&&level1==Column[num]-2&&Room1-1==Row[num]||level2==Column[num]-2&&Room2-1==Row[num]||level3==Column[num]-2&&Room3-1==Row[num]||level4==Column[num]-2&&Room4-1==Row[num]||level1==Column[num]&&Room1-1==Row[num]||level2==Column[num]&&Room2-1==Row[num]||level3==Column[num]&&Room3-1==Row[num]||level4==Column[num]&&Room4-1==Row[num]||level1>=21||level2>=21||level3>=21||level4>=21)
return 1;
else
return 0;
}

int Checker5(int num)
{
if(level1==Column[num]-1&&Room1+1==Row[num]||level2==Column[num]-1&&Room2+1==Row[num]||level3==Column[num]-1&&Room3+1==Row[num]||level4==Column[num]-1&&Room4+1==Row[num]||level1==Column[num]&&Room1+1==Row[num]||level2==Column[num]&&Room2+1==Row[num]||level3==Column[num]&&Room3+1==Row[num]||level4==Column[num]&&Room4+1==Row[num])
return 1;
else
return 0;
}

int Checker6(int num)
{
if(level1==Column[num]-1&&Room1-1==Row[num]||level2==Column[num]-1&&Room2-1==Row[num]||level3==Column[num]-1&&Room3-1==Row[num]||level4==Column[num]-1&&Room4-1==Row[num]||level1==Column[num]&&Room1-1==Row[num]||level2==Column[num]&&Room2-1==Row[num]||level3==Column[num]&&Room3-1==Row[num]||level4==Column[num]&&Room4-1==Row[num])
return 1;
else
return 0;
}

Views: 0

Tags: C++, code, developemnt, for, free, game, games, gaming, source

Comment

You need to be a member of KOLKATA network ... to add comments!

Join KOLKATA network ...

Share CLICK ON THE FACEBOOK SHARE BUTTON "f Share", AND YOU HAVE A CHANCE TO WIN AN iPHONE.
Kolkata (help•info) (Bengali: কলকাতা ; IPA: [ˈkolkat̪a]), formerly Calcutta (help•info), is the capital of the Indian state of West Bengal. It is located in eastern India on the east bank of the River Hooghly.[1] When referred to as Calcutta, it usually includes the suburbs, and thus its population exceeds 15 million,[2] making it India's third-largest metropolitan area and urban agglomeration. This also makes it the world's 8th largest metropolitan area as defined by the United Nations.[3] Kolkata served as the capital of India during the British Raj until 1911. Once the centre of modern education, industry, science, culture and politics in India, Kolkata has witnessed intense political violence, clashes and economic stagnation since 1954. Since the year 2000, economic rejuvenation has spurred on the city's growth. Like other metropolitan cities in India, Kolkata continues to struggle with the problems of urbanisation: poverty, pollution and traffic congestion. Kolkata is noted for its revolutionary history, ranging from the Indian struggle for independence to the leftist and trade union movements.
ImpArt

Promote your Page too

© 2012   Created by KolkataNetwork.com.

Badges  |  Report an Issue  |  Terms of Service