예제 #1
1
void main()
{
 title();
 int k=1,a=9;
 clrscr();
 cout<<"How many players do you want (2-4) :";
 cin>>n;

 if (n<2||n>4)
  {
	cout<<"Error";
	getch();
	exit(0);
  }

 while(a>=0)
 {
  for(int i=0;i<10;i++)
	mat[a][i]=k++;
  a--;
  for(i=9;i>=0;i--)
	mat[a][i]=k++;
  a--;
 }

 for(k=0;k<n;k++)
 {
  cout<<"Player "<<k+1<<" Enter initial :";
  cin>>pini[k][0];
  pini[k][1]='\0';
 }

 clrscr();
 a=DETECT;
 initgraph(&a,&k,"C:\\TC\\BGI");
 while (victory==0)

  for(int i=0;i<n;i++)
  {
	cleardevice();
	grid();

	for(int j=0;j<n;j++)
	 for(int y=0;y<10;y++)
	  for(int x=0;x<10;x++)
		if (mat[y][x]==player[j])
		 showcounter(x,y,j);

	char g[20];
	settextjustify(0,1);
	settextstyle(2,0,5);
	sprintf(g,"Player %d:Your chance",i+1);
	setcolor(BLACK);
	outtextxy(480,20,g);
	randomize();
	int dice=rand()%6+1;
	while(!kbhit())
	for(int z=1;z<7;z++)
	{
	 diceshow(z);
	 delay(50);
	}
	getch();

	diceshow(dice);
	getch();
	if (player[i]+dice>100) continue;
	player[i]+=dice;

	for(k=1;k<n;k++)
	 for(j=0;j<n;j++)
	  if (player[i]==player[j]&&i!=j)
		player[i]++;

	for(j=0;j<17;j++)
	{
	 if(player[i]==snl[j][0])
	  player[i]=snl[j][1];
	}

	for(k=1;k<n;k++)
	 for(j=0;j<n;j++)
	  if (player[i]==player[j]&&i!=j)
		player[i]++;

	for(j=0;j<17;j++)
	{
	 if(player[i]==snl[j][0])
	  player[i]=snl[j][1];
	}

	if(player[i]==100)
	 {
	  victory=i+1;
	  break;
	 }

  }
 cleardevice();
 setcolor(RED);
 rectangle(24,24,616,456);
 setfillpattern(0,RED);
 floodfill(0,0,RED);
 settextjustify(1,1);
 char g[40];
 sprintf(g,"Winner is Player %d.CONGRATULATIONS.",victory);
 settextstyle(3,0,3);
 outtextxy(310,239,g);
 getch();
}
예제 #2
0
int main() {
	int unidad = 0,modo;
	char p[8] = { 0xAB,0xAA,0xAC,0xAA,0x12,0x34,0x45,0x56 };

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	setpalette (3,RED);
	setcolor(3);
	rectangle (100,100,getmaxx(),getmaxy() );
	getch();
	setpalette (4,GREEN);
	setcolor(4);
	rectangle (50,50,200,300);
	getch();
	setpalette (15,BLUE);
	setfillpattern (p,15);
	floodfill (101,101,4);
	getch();
	closegraph();
   return 0;
}
예제 #3
0
void user_pattern()
{
	int n,prec;
	n=17;
	prec=cur_color;
	if(cur_color==BLACK)
	cur_color=WHITE;
	setfillstyle(12,cur_color);
	setfillpattern(pat_fil[0],cur_color);
	bar((4+n*20),4,(16+n*20),16);
	n++;
	setfillpattern(pat_fil[1],cur_color);
	bar((4+n*20),4,(16+n*20),16);
	n++;
	setfillpattern(pat_fil[2],cur_color);
	bar((4+n*20),4,(16+n*20),16);
	n++;
	cur_color=prec;
}
void Intro()
{
   int i;
   char pattern[8] ={0xfe,0xbc,0xda,0xe4,0xe2,0xc0,0x88,0x00};
   setfillpattern(pattern,1);
   bar(0,0,640,480);
   settextstyle(1,0,5);
   setcolor(10);
   getch();
   setcolor(0);
   for(i=0;i<=320;i++)
   {
   rectangle(0+i,0,640-i,480);
   delay(5);
   }
  //   win("BRAINVITA",1,1,638,478,1);
}
예제 #5
0
void zoomin()
{
int m,rad=getmaxy()/2-40,x1=getmaxx()/2,y1=getmaxy()/2,i;
char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27, 0x04, 0x04};
clrscr();
setfillpattern(pattern,RED);
bar3d(0,0,getmaxx(),getmaxy(),2,2);
bar(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxy()-2);
setfillstyle(SOLID_FILL,RED);
setcolor(WHITE);
bar(80,80,getmaxx()-80,getmaxy()-80);
for(i=80;i<=90;i++)
{
delay(80);
rectangle(i,i,getmaxx()-i,getmaxy()-i);
}
setcolor(BLACK);
settextstyle(1,0,5);
outtextxy(187,95,"Developed By");
outtextxy(187,330,"Developed By");
settextstyle(1,1,5);
setcolor(WHITE);
outtextxy(94,98,"Developed By");
outtextxy(475,98,"Developed By");
setcolor(WHITE);
settextstyle(8,0,3);
outtextxy(220,170," Manohar Negi");
outtextxy(220,210,"  III Semester");
outtextxy(220,250,"  Info. Science");
outtextxy(220,290,"     R.V.C.E. ");
setcolor(11);
rectangle(190,150,450,330);
delay(3000);
for(m=0;m<6;m++)
{
cleardevice();
setcolor(RED);
circle(x1,y1,rad);
circle(x1,y1,rad-2);
rad=rad-50;
delay(200);
}
exit(0);
}
예제 #6
0
void title()
{
 int a=DETECT,b;
 initgraph(&a,&b,"c:\\tc\\bgi");
 int j=0;
 setbkcolor(15);
 setcolor(BROWN);
 setlinestyle(0,0,3);
 line(60,190,580,190);
 line(60,210,580,210);
 for (int i=70;i<580;i+=20)
 line(i,190,i,210);
 setlinestyle(0,0,1);
 setcolor(RED);
 settextjustify(1,1);
 settextstyle(1,0,3);
 outtextxy(320,400,"PRESS ANY KEY TO CONTINUE");
 while(!kbhit())
 {
  for(i=1;i<15;i++)
	{
	 if (i<=7) sound(200*i);
	 else sound(200*(15-i));
	 setfillpattern(0,i);
	 setcolor(i);
	 rectangle(24,24,616,456);
	 floodfill(0,0,i);
	 settextjustify(1,1);
	 settextstyle(9,0,4);
	 outtextxy(320,150,"SNAKES & LADDERS");
	 settextstyle(1,0,2);
	 settextjustify(0,1);
	 outtextxy(250,250,"Made by:-Ankit Jain & Rahul Jain");
	 delay(20);
	 nosound();
	}
  }
 graphdefaults();
 closegraph();
}
예제 #7
0
void user_text(int x,int y)
{
	char text[2],ch,sp,bg;
	int i=0,ind;
	int flag=1;
	hidemouseptr();
	x=x/16;
	x=x*16;
	y=y/16;
	y=y*16;
	while(flag)
	{
		while((_bios_keybrd(_KEYBRD_READY)==0))
		{
			setcolor(BLACK);
			line(x-1,y-1,x-1,y+10);
			i=1;
		}
		setcolor(WHITE);
		line(x-1,y-1,x-1,y+10);
		setfillstyle(12,WHITE);
		ch=_bios_keybrd(_KEYBRD_READ);
		if(i==0)
			continue;
		if(x>xmax-16)
			{
			x=0;
			y+=16;
			}
		if(y>ymax-16)
			break;
		else
		{
			i=0;
			switch(ch)
			{
				case 27:
					flag=0;
					break;
				case 13:
					y+=16;
					x=0;
					break;
				case 32:
					x+=16;
					break;
				case 8:
					x-=16;
					setfillstyle(1,WHITE);
					bar(x,y,x+7,y+7);
					break;
				default:
					if((ch>=65&&ch<=90)||(ch>=97&&ch<=122)||(ch>=48&&ch<=57))
					{
						if(ch<58)
						ind=(ch-'0')+26;
						else if(ch<91)
						ind=(ch-'A');
						else if(ch<123)
						ind=(ch-'a');
						bg=getpixel(x,y);
						setfillpattern(pat[ind],RED);
						bar(x,y,x+7,y+7);
						adjust(x,y,x+7,y+7,bg);
						x+=16;
					}
					else
					{
						text[0]=ch;
						text[1]='\0';
						setcolor(cur_color);
						settextstyle(0,0,1);
						outtextxy(x,y,text);
						x+=16;
					}
			}
		}	
	}
	showmouseptr();
 }