Exemplo n.º 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();
}
Exemplo n.º 2
0
void shakil::save1()
{ long int pp[5],cc=0,i1,pp1[5]={0};
  FILE *p11,*p22,*p33,*p44,*p1;
  p11=fopen("sav11","r");
  fscanf(p11,"%ld",&pp[0]);
  if(pp[0]==1)
  fscanf(p11,"%ld",&pp1[0]);
  fclose(p11);
  p22=fopen("sav22","r");
  fscanf(p22,"%ld",&pp[1]);
  if(pp[1]==1)
  fscanf(p11,"%ld",&pp1[1]);
  fclose(p22);
  p33=fopen("sav33","r");
  fscanf(p33,"%ld",&pp[2]);
  if(pp[2]==1)
  fscanf(p11,"%ld",&pp1[2]);
  fclose(p33);
  p44=fopen("sav44","r");
  fscanf(p44,"%ld",&pp[3]);
  if(pp[3]==1)
  fscanf(p11,"%ld",&pp1[3]);
  fclose(p44);
  pp[4]=5;pp1[4]=0;
  for(i=1;i<=5;i++)
  {setcolor(123);
   rectangle(521,250+i*20+4,630,270+i*20);
     setfillstyle(SOLID_FILL,123);
     floodfill(530,250+i*20+6,123);
   setcolor(RED);
   if(pp[i-1]==0)
    outtextxy(525,250+i*20,"EMPTY");
    if(pp[i-1]==1)
    outtextxy(525,250+i*20,"FULL");
    if(pp[i-1]==5)
    outtextxy(525,250+i*20,"EXIT");
    if(pp1[i-1]!=0)
    { setcolor(RED);
     switch(pp1[i-1])
    {case 2:outtextxy(565,250+i*20,"(2:2)");
	  break;
   case 3:outtextxy(565,250+i*20,"(3:3)");
	  break;
   case 4:outtextxy(565,250+i*20,"(4:4)");
	  break;
   case 5:outtextxy(565,250+i*20,"(5:5)");
	  break;
   case 6:outtextxy(565,250+i*20,"(6:6)");
	  break;
   case 7:outtextxy(565,250+i*20,"(7:7)");
	  break;
   case 8:outtextxy(565,250+i*20,"(8:8)");
	  break;
   case 9:outtextxy(565,250+i*20,"(9:9)");
	  break;
   case 10:outtextxy(565,250+i*20,"(10:10)");
	  break;
   case 11:outtextxy(565,250+i*20,"(11:11)");
	  break;
   }
    }
    }
    while(1)
    {getmousepos(&button,&x,&y);
     if((button & 1)==1)
     {if(x>=521&&x<=630)
      for(i1=1;i1<=5;i1++)
      {tm=250+i1*20+4;tm1=270+i1*20;
      if(y>tm&&y<tm1)
      {switch(i1)
       {case 1:
		p1=fopen("sav11","w");
		fprintf(p1,"1 %ld",n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fprintf(p1," %ld %ld",res1[i][j],vm[i][j]);
		fclose(p1);
		break;
	case 2:
		p1=fopen("sav22","w");
		fprintf(p1,"1 %ld",n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fprintf(p1," %ld %ld",res1[i][j],vm[i][j]);
		fclose(p1);
		break;
	case 3:
		p1=fopen("sav33","w");
		fprintf(p1,"1 %ld",n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fprintf(p1," %ld %ld",res1[i][j],vm[i][j]);
		fclose(p1);
		break;
	case 4:
		p1=fopen("sav44","w");
		fprintf(p1,"1 %ld",n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fprintf(p1," %ld %ld",res1[i][j],vm[i][j]);
		fclose(p1);
		break;
	case 5:
	       break;
       }

       cc=5;
       break;
      }}
     }
     if(cc==5)
     break;
    }
  hidemouseptr();
  cleardevice();
  showmouseptr();

}
Exemplo n.º 3
0
void controls()
{
   int x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,i;
   setcolor(0);
   rectangle(61,83,410,259);
   setfillstyle(1,9);
   floodfill(107,137,0);
   arc(62,166,270,90,16);
   setfillstyle(1,6);
   floodfill(68,165,0);

   x1=62;
   y1=67;
   x2=84;
   y2=83;
   x3=73;
   y3=73;
   for(i=0;i<8;i++)
   {
     rectangle(x1,y1,x2,y2);
     x1+=46;
     x2+=46;
     setfillstyle(1,14);
     floodfill(x3,y3,0);
     x3+=46;
   }
   x1=62;
   y1=259;
   x2=84;
   y2=275;
   x3=72;
   y3=267;
   for(i=0;i<8;i++)
   {
     rectangle(x1,y1,x2,y2);
     x1+=46;
     x2+=46;
     setfillstyle(1,14);
     floodfill(x3,y3,0);
     x3+=46;
   }
   outtextxy(70,264,"1");
   outtextxy(65,289,"A1");
   outtextxy(116,264,"2");
   outtextxy(112,289,"B1");
   outtextxy(163,264,"3");
   outtextxy(161,289,"Y1");
   outtextxy(207,264,"4");
   outtextxy(205,289,"A2");
   outtextxy(253,264,"5");
   outtextxy(250,289,"B2");
   outtextxy(299,264,"6");
   outtextxy(297,289,"Y2");
   outtextxy(343,264,"7");
   outtextxy(340,289,"GND");
   outtextxy(390,264,"8");
   outtextxy(387,289,"Y");
   outtextxy(65,74,"16");
   outtextxy(62,55,"Vcc");
   outtextxy(111,74,"15");
   outtextxy(112,54,"A4");
   outtextxy(158,74,"14");
   outtextxy(159,54,"B4");
   outtextxy(204,74,"13");
   outtextxy(205,54,"Y4");
   outtextxy(250,74,"12");
   outtextxy(248,54,"A3");
   outtextxy(295,74,"11");
   outtextxy(297,54,"B3");
   outtextxy(340,74,"10");
   outtextxy(337,54,"Y3");
   outtextxy(394,74,"9");
   outtextxy(387,54,"bv");
   settextstyle(1,0,4);
   setlinestyle(0,0,3);
   setcolor(15);
   line(440,60,599,60);
   line(440,60,440,220);
   setcolor(0);
   line(440,220,599,220);
   line(599,220,599,60);
   setlinestyle(1,0,1);
   setfillstyle(1,0);
   setcolor(0);
   bar(447,63,592,90);
   settextstyle(1,0,1);
   setcolor(14);
   outtextxy(460,68,"RESULTS");
   setcolor(2);
   for(y1=102,i=0;i<4;i++)
   {
     circle(462,y1,10);
     setfillstyle(1,4);
     floodfill(462,y1,2);
     y1+=30;
   }
   setlinestyle(0,0,1);

   setcolor(15);
   line(120,400,190,400);
   line(120,400,120,450);
   setcolor(0);
   line(120,450,190,450);
   line(190,450,190,400);
   setcolor(0);
   outtextxy(130,410,"Index");
   setcolor(15);
   line(250,400,320,400);
   line(250,400,250,450);
   setcolor(0);
   line(250,450,320,450);
   line(320,450,320,400);
   outtextxy(260,410,"Exit");
   settextstyle(1,0,3);
   setcolor(RED);
   outtextxy(150,320,"PIN DIAGRAM");
   setlinestyle(0,0,3);
   line(150,350,297,350);

   setlinestyle(0,0,3);
   setcolor(15);
   line(420,270,600,270);
   line(420,270,420,440);
   setcolor(0);
   line(420,440,600,440);
   line(600,440,600,270);

   bar(422,272,596,310);
   setcolor(14);
   outtextxy(425,280,"Truth Table");
   setcolor(MAGENTA);
   line(430,320,590,320);
   line(430,320,430,430);
   line(430,430,590,430);
   line(590,430,590,320);
   line(530,320,530,430);
   setcolor(BROWN);
   settextstyle(0,0,1);
   outtextxy(460,330,"INPUTS");
   outtextxy(540,3330,"OUTPUT");
   setcolor(MAGENTA);
   line(430,345,590,345);
   line(480,345,480,430);
   setcolor(12);
   outtextxy(450,355,"L");
   outtextxy(500,355,"L");
   outtextxy(560,355,"L");
   outtextxy(450,375,"L");
   outtextxy(500,375,"H");
   outtextxy(560,375,"L");
   outtextxy(450,395,"H");
   outtextxy(500,395,"L");
   outtextxy(560,395,"L");
   outtextxy(450,415,"H");
   outtextxy(500,415,"H");
   outtextxy(560,415,"H");
   setcolor(MAGENTA);
   line(430,370,590,370);
   line(430,390,590,390);
   line(430,410,590,410);
   line(430,430,590,430);
}
Exemplo n.º 4
0
void main()
{
  int gd=DETECT,gm,sec=0,hour,min,x1=0,y1=0,x2=0,y2=0,x3=0,y3=0;
  char *k[12]={"1","2","3","4","5","6","7","8","9","10","11","12"};
  struct time t;
  initgraph(&gd,&gm,"");
  setcolor(YELLOW);
  circle(300,200,200);
  circle(300,200,180);
  setfillstyle(1,RED);
  floodfill(300,390,YELLOW);
  settextstyle(DEFAULT_FONT,0,2);
//----------------------Constants----------------------//

  int a,b;
  for(int i=1;i<13;i++)
    {
	a=160*cos(arg_hour*i-M_PI_2);
	b=160*sin(arg_hour*i-M_PI_2);
	outtextxy(a+300,b+200,k[i-1]);
    }

//----------------------Constants----------------------//
/*****************************************************
		 1-Good
		 2-Small
		 3-Watse
		 4-caligraphy
		 5-cursive
		 6-good
		 7-excellent
		 8-Good
		 9-Big
		 10-Double
 ****************************************************/
 int dig_sec;
 char Time_Dig[14];
  while(!kbhit())
   {
       settextstyle(7,0,4);
      outtextxy(264,100,"Satya");
      settextstyle(7,0,1);
      outtextxy(278,280,"Quartz");
      setcolor(BLACK);
      line(300,200,x1+300,y1+200);
      line(300,200,x2+300,y2+200);
      line(300,200,x3+300,y3+200);
      gettime(&t);
      if(sec!=t.ti_sec)
	{
	   sound(5000);
	   delay(1);
	   nosound();
	}
      hour=t.ti_hour;
      sec=t.ti_sec;
      min=t.ti_min;
      Time_Dig[0]=hour/10+48;
      Time_Dig[1]=hour%10+48;
      Time_Dig[2]=':';
      Time_Dig[3]=min/10+48;
      Time_Dig[4]=min%10+48;
      Time_Dig[5]=':';
      Time_Dig[6]=sec/10+48;
      Time_Dig[7]=sec%10+48;
      Time_Dig[8]='\0';
      outtextxy(270,250,"ллллллллллллллллл");
      x1=150*cos(arg_sec*sec-M_PI_2)*0.98;
      y1=150*sin(arg_sec*sec-M_PI_2)*0.98;
      x2=150*cos(arg_sec*min-M_PI_2)*0.9;
      y2=150*sin(arg_sec*min-M_PI_2)*0.9;
      if(hour>12) hour-=12;
      x3=150*cos(arg_hour*hour-M_PI_2+arg_min*min)*0.6;
      y3=150*sin(arg_hour*hour-M_PI_2+arg_min*min)*0.6;
      setcolor(YELLOW);
      line(300,200,x1+300,y1+200);
      setcolor(CYAN);
      line(300,200,x2+300,y2+200);
      setcolor(WHITE);
      line(300,200,x3+300,y3+200);
      setcolor(YELLOW);
      outtextxy(270,250,Time_Dig);
      delay(50);

   }

  getch();
  closegraph();
  restorecrtmode();
}
Exemplo n.º 5
0
void Graphics::FloodFill(int x, int y)
{
    floodfill(_alBitmap, x, y, _drawColor);
}
Exemplo n.º 6
0
int game(int where, int where_num)
{
	MOUSEMSG m;
	int temp_x, temp_y, i, j, flag = 0, num = 480/where;
	int step = 0;

	while (1)
	{
		m = GetMouseMsg();
		if (m.uMsg == WM_LBUTTONDOWN && m.x < 480)
		{
			if (m.x == num || m.y == num)
			{
				continue;
			}
			mciSendString("open audio/change.mp3 alias change", NULL, 0, NULL);
			mciSendString("play change", NULL, 0, NULL);
			step += 1;
			temp_x = m.x/num;
			temp_y = m.y/num;
			if (map_check[temp_y][temp_x] == 0)
			{
				setfillstyle(RED);
				floodfill(m.x, m.y , GREEN);
				map_check[temp_y][temp_x] = 1;
			}
			else
			{
				setfillstyle(BLACK);
				floodfill(m.x, m.y, GREEN);
				map_check[temp_y][temp_x] = 0;
			}
			if (temp_x - 1 >= 0)
			{
				if (map_check[temp_y][temp_x-1])
				{
					setfillstyle(BLACK);
					floodfill(m.x - num, m.y, GREEN);
					map_check[temp_y][temp_x-1] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x - num, m.y, GREEN);
					map_check[temp_y][temp_x-1] = 1;
				}
			}
			if (temp_y - 1 >= 0)
			{
				if (map_check[temp_y-1][temp_x])
				{
					setfillstyle(BLACK);
					floodfill(m.x, m.y - num, GREEN);
					map_check[temp_y-1][temp_x] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x, m.y - num, GREEN);
					map_check[temp_y-1][temp_x] = 1;
				}
			}
			if (temp_x + 1 < where)
			{
				if (map_check[temp_y][temp_x+1])
				{
					setfillstyle(BLACK);
					floodfill(m.x + num, m.y, GREEN);
					map_check[temp_y][temp_x+1] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x + num, m.y , GREEN);
					map_check[temp_y][temp_x+1] = 1;
				}
			}
			if (temp_y + 1 < where)
			{
				if (map_check[temp_y+1][temp_x])
				{
					setfillstyle(BLACK);
					floodfill(m.x, m.y + num, GREEN);
					map_check[temp_y+1][temp_x] = 0;
				}
				else
				{
					setfillstyle(RED);
					floodfill(m.x, m.y + num, GREEN);
					map_check[temp_y+1][temp_x] = 1;
				}
			}
			Sleep(200);
			mciSendString("stop change", NULL, 0, NULL);
			mciSendString("close change", NULL, 0, NULL);
		}
		for (i = 0; i < where && !flag; i++)
		{
			for (j = 0; j < where && !flag; j++)
			{
				if (map_check[i][j] == 0)
				{
					flag = 1;
				}
			}
		}
		game_info(flag, step, where_num);
		if (flag == 0)
		{
			break;
		}
		flag = 0;
	}
	return 0;
}
Exemplo n.º 7
0
void show()
{
  cleardevice();
  setcolor(RED);
  rectangle(40,40,600,450);

  setcolor(RED);
  line(sa[0],sa[1],sa[2],sa[3]);
  rectangle(sa[0],sa[1],sa[2],sa[3]+5);
  setfillstyle(SOLID_FILL,RED);
  floodfill((sa[0]+sa[2])/2,(sa[1]+sa[3]+5)/2,RED);
  circle(sa1[0],sa1[1],r1);
  setfillstyle(SOLID_FILL,RED);
  floodfill(sa1[0]+1,sa1[1]+1,RED);
  setcolor(RED);
  for(i=0;i<30;i++)
  if(bool3[i]==1)
  { setcolor(rand()%5+1);
   circle(bool1[i],bool2[i],28);
    }

  for(i=0;i<kk;i++)
  {if(sin3[i]!=0)
   if(sin2[i]<=445)
   { sin2[i]=sin2[i]+5;
     circle(sin1[i],sin2[i],sin3[i]);
     switch(sin3[i])
     {case 12:outtextxy(sin1[i]-5,sin2[i],"+1");
	      break;
     case 14:outtextxy(sin1[i]-5,sin2[i],"-1");
	     break;
     case 16:outtextxy(sin1[i]-5,sin2[i],"+");
	      break;
     case 18: outtextxy(sin1[i]-5,sin2[i],"-");
	      break;
     case 8:outtextxy(sin1[i]-5,sin2[i],"@");
	     break;
     case 10:outtextxy(sin1[i]-5,sin2[i],"*");
	     break;
     case 6:outtextxy(sin1[i]-2,sin2[i],"O");
	     break;
     case 4:outtextxy(sin1[i]-1,sin2[i],"o");
	     break;
     }
    if(sin1[i]>=sa[0]&&sin1[i]<=sa[2])
    {
     if(sin2[i]+sin3[i]>=sa[1])
    {
     switch(sin3[i])
    {case 12:li=li+1;break;
     case 14:outtextxy(140,350,"LIFE LOSE");
	     li=li-1;score=score-50;
	     delay(2000);
	     if(li==0)
	    {cleardevice();
	     outtextxy(140,380,"GAME OVER AND YOUR SCORE");
	     printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n            %ld",score);
	     delay(4000);

	     fil();
	       }
	     get();
	     break;
     case 16:r=r*2;score=score+100;break;
     case 18:r=r/2;break;
     case 8:mn=20;score=score+100;break;
     case 10:powe=powe*powe;score=score+100;break;
     case 6:r1=r1*2;score=score+100;
	   break;
     case 4:r1=r1/2;
	    break;
     }

     sin3[i]=0;
     }}
   }
  }

}
Exemplo n.º 8
0
int main()
{
    int gd = DETECT, gm;
    int i, maxx, midy;
 
    /* initialize graphic mode */
    initgraph(&gd, &gm, "NULL");
    /* maximum pixel in horizontal axis */
    maxx = getmaxx();
    /* mid pixel in vertical axis */
    midy = getmaxy()/2;
 
    for (i=0; i < maxx-150; i=i+5)	/* loop is run for showing the animation */
    {
        /* clears screen */
        cleardevice();
 
        /* draw a white road */
        setcolor(WHITE);	/* color of the road */
        line(0, midy + 37, maxx, midy + 37);
 
        /* Draw Car */
        setcolor(YELLOW);	/* color of the car body */

 	/* car body */
        line(i, midy + 23, i, midy);	/* draws the left most line parallel to y-axis */
        line(i, midy, 40 + i, midy - 20);
        line(40 + i, midy - 20, 80 + i, midy - 20);	/* draws the roof of the car*/
        line(80 + i, midy - 20, 100 + i, midy);		/* draws the front mirror part of the car */
        line(100 + i, midy, 120 + i, midy);
        line(120 + i, midy, 120 + i, midy + 23);
        line(0 + i, midy + 23, 18 + i, midy + 23);
        arc(30 + i, midy + 23, 0, 180, 12);		/* draws the arc to accomodate the wheels */
        line(42 + i, midy + 23, 78 + i, midy + 23);
        arc(90 + i, midy + 23, 0, 180, 12);		/* draws the arc to accomodate the wheels */
        line(102 + i, midy + 23, 120 + i, midy + 23);
	/* car body ends */

	/* Draw Windows */
	/* left window */
        line(28 + i, midy, 43 + i, midy - 15);		/* left part of left window */
        line(43 + i, midy - 15, 57 + i, midy - 15);	/* roof of the left window */
        line(57 + i, midy - 15, 57 + i, midy);		/* right part of left window */
        line(57 + i, midy, 28 + i, midy);		/* bottom part of the left window */
	/* left window ends */

	/* right window */
        line(62 + i, midy - 15, 77 + i, midy - 15);	/* left part of right window */
        line(77 + i, midy - 15, 92 + i, midy);		/* roof of the rightt window */
        line(92 + i, midy, 62 + i, midy);		/* right part of right window */
        line(62 + i, midy, 62 + i, midy - 15);		/* bottom part of the right window */
	/* right window ends */

        floodfill(5 + i, midy + 22, YELLOW);	/* fills the whole car body with yellow color */

        setcolor(BLUE);		/* color of the wheels */
        /*  Draw Wheels */
        circle(30 + i, midy + 25, 9);
        circle(90 + i, midy + 25, 9);
        floodfill(30 + i, midy + 25, BLUE);	/* fills the left wheel with blue color */
        floodfill(90 + i, midy + 25, BLUE);	/* fills the right wheel with blue color */

        /* Add delay of 0.1 milli seconds */
        delay(100);	/* to observe the animation */
    }
 
    getch();
    closegraph();
    return 0;
}
Exemplo n.º 9
0
void main()
{	/* main()开始 */
	int gdriver=VGA,gmode=VGAHI;
	int direc;
	char ch,ch2;
	int step,len,size,x,y,i,j;
	initgraph(&gdriver,&gmode,"c:\\tc");
Startgame:
	step=20;
	len=10;
	size=20;
	x=0;
	y=0;
	i=0;
	j=0;
	makebg(M,N);
	cleardevice();
	setbkcolor(LIGHTBLUE);
	setwritemode(XOR_PUT);
	settextstyle(1,0,3);
	/*setcolor(GREEN);
	outtextxy(100,180,"Press <Q> to quit");*/
	setcolor(RED);
	setfillstyle(LINE_FILL,RED);
	drawbg(bg,M,N,size,0,0);
	setcolor(WHITE);
	x+=len;y+=len;
	drawman(x,y,len);
	gotoxy(60,3);
	printf("M-by Manual");
	gotoxy(60,6);
	printf("C-by Computer");
	gotoxy(60,9);
	printf("Please choice:");
	setcolor(WHITE);
	while(1)
	{
		ch=getch();
		if(ch=='M'||ch=='m')
		{
			/* 人工控制 */
			gotoxy(60,3);
			printf("A-Left     ");
			gotoxy(60,6);
			printf("D-Right      ");
			gotoxy(60,9);
			printf("W-Up           ");
			gotoxy(60,12);
			printf("S-Down");
			gotoxy(60,15);
			printf("Q-Quit");
			while(1)
			{
				ch=getch();
				drawman(x,y,len);
				if(ch=='Q'||ch=='q')
				{
					/*按了Q键,退出游戏*/
					gotoxy(60,18);
					printf("You have press");
					gotoxy(60,19);
					printf("Q key! Do you");
					gotoxy(60,20);
					printf("Want to quit?");
					gotoxy(60,21);
					printf("OK?[Y/N]");
					while(1)
					{
						ch2=getch();
						if(ch2=='Y'||ch2=='y')
						{
							closegraph();
							clrscr();
							exit(0);
						}
						else if(ch2=='N'||ch2=='n')
							goto Startgame;
					}
					
				}
			  	switch(ch)
			  	{
			    		case 'a':
			    		case 'A':
			       			if(j>0&&bg[i][j-1]==0)
			       			{
			            			if(x>step)
			            			{
			            				x-=step;
			            				j--;
			            			}
			       			}
			        		break;
					case 's':
					case 'S':
					        if(i<M-1&&bg[i+1][j]==0)
					        {
					            if(y<479-step)
					            {
					            	y+=step;
					            	i++;
					            }
					        }
					        break;
					case 'd':
					case 'D':
					        if(j<N-1&&bg[i][j+1]==0)
					        {
					            if(x<639-step)
					            {
					            	x+=step;
					            	j++;
					            }
					        }
					        break;
					case 'w':
					case 'W':
					        if(i>0&&bg[i-1][j]==0)
					        {
					            if(y>step)
					            {
					            	y-=step;
					            	i--;
					            }
					        }
					        break;
					default :break;
		  		}
		  		drawman(x,y,len);
		 		delay(800);
		 		if(i>=M-1&&j>=N-1)
		 		{
		    			setcolor(LIGHTGREEN);
					rectangle(450,300,620,380);
		    			setfillstyle(SOLID_FILL,LIGHTGRAY);
					floodfill(480,360,LIGHTGREEN);
		    			settextstyle(0,0,1);
		    			setcolor(MAGENTA);
					outtextxy(455,325,"You won the game!");
					outtextxy(455,355,"Press Q to quit...");
		    			while(1)
		    			{
						ch2=getch();
						if(ch2=='Q'||ch2=='q')
							break;
					}
					closegraph();
					clrscr();
					exit(0);
		    			/*
		    			settextstyle(4,0,3);
		    			setcolor(RED);
		    			outtextxy(150,260,"YOU WIN!");*/
		 		}
			}
			
		}/* 人工控制结束 */
		
		else if(ch=='C'||ch=='c')
		{
			/* 电脑控制 */
			/* direc表示上一步运动方向 */
			/* 并表示下一步运动方向 */
			/* 0~3分别表示 西、北、东、南 */
			gotoxy(60,3);
			printf("Computer now");
			gotoxy(60,6);
			printf("Run the maze");
			gotoxy(60,9);
			printf("Automatically...");
			direc=2;
			i=j=0;
			while(i<M-1||j<N-1)
			{
			    	delay(80000);
			    	drawman(x,y,len);
			   	switch(direc)
			    	{
			    		case 0:
			        		/* 以3,0,1的次序尝试 */ 
			        		if(i<M-1&&bg[i+1][j]==0){
			            			y+=step;i++;
			            			direc=3; 
			        		}    
			        		else if(j>0&&bg[i][j-1]==0){
			            			x-=step;j--;
			            			direc=0;            
			        		}
					        else if(i>0&&bg[i-1][j]==0){
					            y-=step;i--;
					            direc=1;            
					        }
					        else {
					            x+=step;j++;
					            direc=2;            
					        }              
					        break;
			    		case 1:
					        if(j>0&&bg[i][j-1]==0){
					            x-=step;j--;
					            direc=0;            
					        }
					        else if(i>0&&bg[i-1][j]==0){
					            y-=step;i--;
					            direc=1;            
					        }
					        else if(j<N-1&&bg[i][j+1]==0){
					            x+=step;j++;
					            direc=2;            
					        }
					        else{
					            y+=step;i++;
					            direc=3; 
					        }                      
					        break;
					case 2:
					        if(i>0&&bg[i-1][j]==0){
					            y-=step;i--;
					            direc=1;  
					        }    
					        else if(j<N-1&&bg[i][j+1]==0){
					            x+=step;j++;
					            direc=2;            
					        }
					        else if(i<M-1&&bg[i+1][j]==0){
					            y+=step;i++;
					            direc=3; 
					        } 
					        else {
					            x-=step;j--;
					            direc=0;
					        }   
					        break;
					case 3:
					        if(j<N-1&&bg[i][j+1]==0){
					            x+=step;j++;
					            direc=2;            
					        }
					        else if(i<M-1&&bg[i+1][j]==0){
					            y+=step;i++;
					            direc=3; 
					        }
					        else if(j>0&&bg[i][j-1]==0){
					            x-=step;j--;
					            direc=0;
					        } 
					        else {
					            y-=step;i--;
					            direc=1;  
					        }
					        break;
					default :break;
			    	}
			    	drawman(x,y,len);
			}
			gotoxy(60,12);
			printf("Finished!");
			gotoxy(60,15);
			printf("Press any");
			gotoxy(60,18);
			printf("Key to quit...");
			getch();
			closegraph();
			clrscr();
			exit(0);
		}/* 电脑控制结束 */
	}
}/* main()结束 */
Exemplo n.º 10
0
int main()
{
int gd=DETECT,gm,i=0,x,y,area;
initgraph(&gd,&gm,"tc:\bgi");//put your directory contains egavga.bgi
rectangle(0,0,getmaxx(),getmaxy());//to find max x and y coordinate in the screen
arc(240,120,40,140,70);//arc(x,y,stangle,endangle,radius);
ellipse(165,80,10,280,20,20);//ellipse (x,y,stangle,endangle,xrad,yrad) ,ears
ellipse(315,80,-100,170,20,20);//ears
arc(235,120,163,215,70);
arc(245,120,-35,17,70);
ellipse(193,178,85,280,40,20);
ellipse(283,178,-100,95,40,20);
ellipse(238,199,180,0,39,50);
ellipse(213,123,44,240,33,40);
ellipse(262,123,-60,135,33,40);
ellipse(210,123,0,360,13,20);//left eye
ellipse(265,123,0,360,13,20);//right eye
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
ellipse(238,160,0,360,10,13);//nose
arc(240,125,228,312,68);//mouth
arc(240,120,230,310,72);//mouth
setfillstyle(1,4);
floodfill(238,100,15);//floodfill(238,160,15);//nose
setfillstyle(1,15);
floodfill(210,113,15);
floodfill(265,113,15);
setfillstyle(1,9);
floodfill(210,100,15);
setfillstyle(1,1);
floodfill(315,80,15);
moveto(203,220);
lineto(203,260);
lineto(183,260);
lineto(183,350);
lineto(293,350);
lineto(293,260);
lineto(273,260);
lineto(273,220);
moveto(183,350);
lineto(173,460);
lineto(213,460);
lineto(238,400); 
lineto(263,460);
lineto(303,460);
lineto(293,350);
moveto(173,460);
lineto(143,478);
lineto(213,478);
lineto(213,460);
moveto(263,460);
lineto(263,478);
lineto(333,478);
lineto(303,460);
line(238,400,238,350);
//right hand
moveto(183,260);
lineto(113,310);
lineto(183,375);
moveto(183,280);
lineto(137,310);
lineto(181,353);
setfillstyle(2,13);
floodfill(190,300,15);
setfillstyle(1,5);
floodfill(223,400,15);
setfillstyle(1,5);
floodfill(253,400,15);
setfillstyle(1,6);
floodfill(173,470,15);
floodfill(303,470,15);
//fingers
secondleft();
ellipse(413.5,228,0,180,3.5,3.5);
line(420,240,433,240);
line(423,247,440,247);
line(413,240,410,228);
line(417,228,420,240);
ellipse(433,243.5,-90,90,3.5,3.5);
line(423,254,440,254);
ellipse(440,250.5,-90,90,3.5,3.5);
ellipse(430,257,-90,90,3,3);
line(413,260,430,260);

area=imagesize(409,224,444,261);
buf=malloc(area);
getimage(409,224,444,261,buf);
while(!kbhit())
{
if(i==0)
{
setfillstyle(1,15);
setcolor(15);
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
setcolor(0);
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
floodfill(210,133,15);
floodfill(265,133,15);
setcolor(0);
putimage(391,209,buf,1);
firstleft();
setcolor(15);
secondleft();
putimage(409,224,buf,0);
i=1;
}
else
{
setfillstyle(1,0);
setcolor(0);
ellipse(210,133,0,360,10,10);//left eye ball
ellipse(265,133,0,360,10,10);//right eye ball
floodfill(210,133,0);
floodfill(265,133,0);
setcolor(15);
ellipse(210,133,0,360,3,3);//left eye ball
ellipse(265,133,0,360,3,3);//right eye ball
floodfill(210,133,15);
floodfill(265,133,15);
setcolor(0);
putimage(409,224,buf,1);
secondleft();
setcolor(15);
firstleft();
putimage(391,209,buf,0);
i=0;
}
delay(300);
}
getch();
return 0;
}
Exemplo n.º 11
0
void Maze::generateKruskal( unsigned long seed, bool frame, bool verbose )
{
	unsigned long i, j, x, y, wallcount;
	std::clock_t timer = std::clock( );
	std::vector <Point> walls;
	Point f[2]; //Fields to compare

	//Quit if not ready
	if ( !this->ready ) return;

	//Random seed
	srand( seed );

	//Fill with 1's
	for ( i = 0; i < this->width; i++ )
		for ( j = 0; j < this->height; j++ )
			this->data[i][j] = 1;

	//Add grid made of walls
	for ( i = 0; i < this->width; i++ )
		for ( j = 0; j < this->height; j++ )
		{
			this->data[i][j] = ( j % 2 ) ? 0 : !( i % 2 ) * ( j * this->width + i + 1 );

			if ( i == this->width - 1 && !( this->width % 2 ) )
				this->data[i][j] = !( j % 2 );

			if ( j == this->height - 1 && !( this->height % 2 ))
				this->data[i][j] = !( i % 2 );
		}

	//List all walls
	for ( i = 0; i < this->width; i++ )
		for ( j = 0; j < this->height; j++ )
			if ( this->data[i][j] == 0 ) walls.push_back( Point( i, j ) );

	wallcount = walls.size( );

	//While there are walls
	while ( walls.size( ) )
	{
		//Random wall
		i = rand( ) % walls.size( );
		x = walls[i].x;
		y = walls[i].y;

		f[0] = f[1] = walls[i];
		f[0].x--;
		f[1].x++;

		if ( get( f[0] ) != get( f[1] ) && get( f[0] ) != 0 && get( f[1] ) != 0 )
		{
			this->data[x][y] = get( f[0] );
			floodfill( x, y, get( f[0] ), get( f[1] ) );
		}
		else
		{
			f[0] = f[1] = walls[i];
			f[0].y--;
			f[1].y++;

			if ( get( f[0] ) != get( f[1] ) && get( f[0] ) != 0 && get( f[1] ) != 0 )
			{
				this->data[x][y] = get( f[0] );
				floodfill( x, y, get( f[0] ), get( f[1] ) );
			}
		}

		walls[i] = walls[walls.size( ) - 1];
		walls.erase( walls.begin( ) + walls.size( ) - 1 ); //Remove wall from walls index
		

		//Output progress message
		if ( verbose ) std::cerr << std::fixed << std::setprecision( 2 ) <<  "\rProgress: " << 100.0 - ( (double)walls.size( ) / (double)wallcount * 100.0 ) << "%";
	}

	//Final cleanup to 1's and 0's
	for ( i = 0; i < this->width; i++ )
		for ( j = 0; j < this->height; j++ )
			this->data[i][j] = this->data[i][j] != 0;

	//Draw frame
	if ( frame )
	{
		for ( i = 0; i < this->width; this->data[i++][0] = 0 ); //Top
		for ( i = 0; i < this->width; this->data[i++][this->height - 1] = 0 ); //Bottom
		for ( i = 0; i < this->height; this->data[0][i++] = 0 ); //Left
		for ( i = 0; i < this->height; this->data[this->width - 1][i++] = 0 ); //Right
	}

	//Output time elapsed
	if ( verbose ) std::cerr << std::fixed << std::setprecision( 2 ) << "\nTime elapsed: " << (double)( std::clock( ) - timer ) / (double)CLOCKS_PER_SEC << "s" << std::endl;
}
Exemplo n.º 12
0
   void main(void)
   {

   int graphmode, graphdriver;
   int curr_mode;

   int posx, posy, dest, x, y;
   int cx, cy, cr;
   float FI, PI, RAIO, RO, TETA,TETA2, X0, Y0, XL, YL, XL1, YL1;
   char tecla;
   int a, b,I;


   detectgraph (&graphdriver, &graphmode);

   initgraph (&graphdriver, &graphmode, "c:\\borlandc\\bgi");


  do{

   PI = 3.14159265358979;
   X0 = 130;
   Y0 = 250;
   I = -90;
   RO = 0;
   FI = 0;
   RAIO=8;

   setfillstyle(1,LIGHTBLUE);
   floodfill(0,0,LIGHTBLUE);

   setcolor(GREEN);
   rectangle(0,280,700,600);
   setfillstyle(1,GREEN);
   floodfill(15,295,GREEN);
   // Arvore
   /*   setcolor(BROWN);
   rectangle(420,320,485,120);
   setfillstyle(1,BROWN);
   floodfill(420,320,BROWN); */
   setcolor(BROWN);
   outtextxy(425,110,"ллллллл");
   outtextxy(425,118,"ллллллл");
   outtextxy(425,126,"ллллллл");
   outtextxy(425,134,"ллллллл");
   outtextxy(425,142,"ллллллл");
   outtextxy(425,150,"ллллллл");
   outtextxy(425,158,"ллллллл");
   outtextxy(425,166,"ллллллл");
   outtextxy(425,174,"ллллллл");
   outtextxy(425,152,"ллллллл");
   outtextxy(425,160,"ллллллл");
   outtextxy(425,168,"ллллллл");
   outtextxy(425,176,"ллллллл");
   outtextxy(425,184,"ллллллл");
   outtextxy(425,192,"ллллллл");
   outtextxy(425,200,"ллллллл");
   outtextxy(425,208,"ллллллл");
   outtextxy(425,216,"ллллллл");
   outtextxy(425,224,"ллллллл");
   outtextxy(425,232,"ллллллл");
   outtextxy(425,240,"ллллллл");
   outtextxy(425,248,"ллллллл");
   outtextxy(425,256,"ллллллл");
   outtextxy(425,264,"ллллллл");
   outtextxy(425,272,"ллллллл");
   outtextxy(425,280,"ллллллл");
   outtextxy(425,288,"ллллллл");
   outtextxy(425,296,"ллллллл");
   outtextxy(425,304,"ллллллл");
   outtextxy(425,312,"ллллллл");

   setfillstyle(1,GREEN);
   setcolor(GREEN);
   circle(410,100,50);
   floodfill(410,100,GREEN);
   setfillstyle(1,GREEN);

   setcolor(GREEN);
   circle(490,100,50);
   floodfill(490,100,GREEN);
   setfillstyle(1,GREEN);

   setcolor(GREEN);
   circle(455,140,40);
   floodfill(455,140,GREEN);
   setfillstyle(1,GREEN);

   setcolor(GREEN);
   circle(455,60,40);
   floodfill(455,60,GREEN);
   setfillstyle(1,GREEN);

   //Alvo
   cx=450;
   cy=250;
   cr=50;



   setfillstyle(1,WHITE);

   //Nuvens
   setcolor(WHITE);
   circle(100,100,cr-40);
   floodfill(100,100,WHITE);
   setfillstyle(1,WHITE);

   setcolor(WHITE);
   circle(120,100,cr-35);
   floodfill(120,100,WHITE);
   setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(140,100,cr-40);
    floodfill(140,100,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(260,50,cr-35);
    floodfill(260,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(280,50,cr-30);
    floodfill(280,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(305,50,cr-30);
    floodfill(305,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(330,50,cr-35);
    floodfill(330,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(540,150,cr-45);
    floodfill(540,150,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(550,150,cr-42);
    floodfill(550,150,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(560,150,cr-42);
    floodfill(560,150,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(570,150,cr-45);
    floodfill(570,150,WHITE);
    setfillstyle(1,YELLOW);
    //Sol
    setcolor(YELLOW);
    circle(570,40,40);
    floodfill(570,40,YELLOW);
    setfillstyle(1,YELLOW);
    //Faca

    do{
    if(X0<=440)
    {
    if(X0==440)
    {
    setfillstyle(1,LIGHTBLUE);
    setcolor(LIGHTBLUE);
    setfillstyle(1,LIGHTBLUE);
    circle(cx,cy,cr);
    floodfill(cx,cy,LIGHTBLUE);
   }
   if((X0>405)&&(X0<420))
    {
    setfillstyle(1,RED);
    setcolor(RED);
    setfillstyle(1,RED);
    circle(cx,cy,cr);
    floodfill(cx,cy,RED);
   }

   if((X0<=135)||(X0==440))
   {setfillstyle(1,RED);
    setcolor(RED);
    circle(cx,cy,cr);
    floodfill(cx,cy,RED);
    setfillstyle(1,LIGHTGRAY);

    setcolor(LIGHTGRAY);
    circle(cx,cy,cr-10);
    floodfill(cx,cy,LIGHTGRAY);
    setfillstyle(1,RED);

   setcolor(RED);
   circle(cx,cy,cr-20);
   floodfill(cx,cy,RED);
   setfillstyle(1,LIGHTGRAY);

   setcolor(LIGHTGRAY);
   circle(cx,cy,cr-30);
   floodfill(cx,cy,LIGHTGRAY);
   setfillstyle(1,RED);

   setcolor(RED);
   circle(cx,cy,cr-40);
   floodfill(cx,cy,RED);
   }
    TETA = PI*I/180;
    XL = X0 + RAIO*cos(TETA)*cos(PI*RO/180);
    YL = Y0 + RAIO*sin(TETA)*cos(PI*FI/180);
    XL1 = X0 - RAIO*cos(TETA)*cos(PI*RO/180);
    YL1 = Y0 - RAIO*sin(TETA)*cos(PI*FI/180);
    /* setcolor(BLUE);
    line(X0,Y0,XL,YL);
    setcolor(BLUE);
    line(X0,Y0,XL1,YL1);*/

    setcolor(WHITE);
    line(X0,Y0,XL,YL);
    setcolor(BROWN);
    line(X0,Y0,XL1,YL1);

    //while (X0>=440);
    //if(X0>=440);

    if(X0<405)
    {
    TETA2 = PI*(I-3)/180;
    XL = X0-2 + RAIO*cos(TETA2)*cos(PI*RO/180);
    YL = Y0 + RAIO*sin(TETA2)*cos(PI*FI/180);
    XL1 = X0-2 - RAIO*cos(TETA2)*cos(PI*RO/180);
    YL1 = Y0 - RAIO*sin(TETA2)*cos(PI*FI/180);
    setcolor(LIGHTBLUE);
    line(X0-2,Y0,XL,YL);
    //setcolor(BROWN);
    line(X0-2,Y0,XL1,YL1);
    }
     if((X0>405) &&(X0<430))
    {
    TETA2 = PI*(I-3)/180;
    XL = X0-2 + RAIO*cos(TETA2)*cos(PI*RO/180);
    YL = Y0 + RAIO*sin(TETA2)*cos(PI*FI/180);
    XL1 = X0-2 - RAIO*cos(TETA2)*cos(PI*RO/180);
    YL1 = Y0 - RAIO*sin(TETA2)*cos(PI*FI/180);
    setcolor(RED);
    line(X0-2,Y0,XL,YL);
    line(X0-2,Y0,XL1,YL1);
    }
    }

   // cleardevice();
    I+=3;
    X0+=2;

    //Homem
    posx=150;
    posy=250;
    dest=10;
    setcolor(14);

    //Tronco
    setcolor(YELLOW);
    line(posx, posy+10, posx, posy+40);

    //Pernas
    line(posx, posy+40, posx+10, (posy+70));
    line(posx, posy+40, posx-10, (posy+70));

    //Bra‡os
    line(posx, posy+18, posx+20, posy+15);
    line(posx, posy+18, posx-15, posy+35);

    //Bra‡o mexendo
    if(X0<=200)
    {
    setcolor(LIGHTBLUE);
    a = (int)( posx+10 + 20*cos(TETA2)*cos(PI*0/180));
    b = (int)( posy+10 + 20*sin(TETA2)*cos(PI*0/180));
    line(posx+20, posy+15, a, b);

    setcolor(YELLOW);
    a = (int)( posx+10 + 20*cos(TETA)*cos(PI*0/180));
    b = (int)( posy+10 + 20*sin(TETA)*cos(PI*0/180));
    line(posx+20, posy+15, a, b);

    }
    line(posx+20,posy+15,a,b);
    delay(10);

    if(X0<200)
    {
    //Cabeca
    setcolor(LIGHTBLUE);
    setfillstyle(1,LIGHTBLUE);
    circle(posx, posy, dest);
    floodfill(posx,posy,LIGHTBLUE);

    }


    //Cabeca
    setcolor(YELLOW);
    setfillstyle(1,YELLOW);
    circle(posx, posy, dest);
    floodfill(posx,posy,YELLOW);



    }while (!kbhit());
    tecla=getch();
    cleardevice();
    }while(tecla!=27);

    closegraph();

    }
void buybuy()
{
     char name[25],pname[25]=" Vanam";
     int i;

     cleardevice();
     setcolor(6);
     settextstyle(1,0,1);
  outtextxy(100,100,"Thanks For  Using This Software !.");
  outtextxy(100,130,"If Any Suggestions Or Defects Regarding This Software.");
  outtextxy(100,160,"Please Send Mail to <*****@*****.**>.");

     settextstyle(5,0,1);
     setcolor(DARKGRAY);
     circle(60,100,22);
     setfillstyle(1,YELLOW);
     floodfill(60,100,DARKGRAY);
     setcolor(LIGHTBLUE);
     outtextxy(45,96,"Sunny");
     setcolor(9);

     for(i=0;pname[i]!=0;i++)
     {
	   name[i]=pname[i];
	   name[i+1]=0;
	   outtextxy(420,250,name);
	   delay(2000);
     }

     setcolor(LIGHTGRAY);
     setfillstyle(1,LIGHTGRAY);
     fillellipse(50,96,6,2);
     fillellipse(70,96,6,2);

     setcolor(BLACK);
     circle(50,96,1);
     circle(70,96,1);
     setcolor(BLACK);
     arc(60,100,205,335,15);
     line(45,108,48,106);
     line(75,108,72,106);
     sleep(1);
     setfillstyle(1,0);
     fillellipse(70,96,6,2);
     sleep(1);

     setfillstyle(1,LIGHTGRAY);
     fillellipse(70,96,6,2);
     circle(70,96,1);
     sleep(1);
     setcolor(BLUE);
     circle(60,100,22);

     setfillstyle(1,BLACK);
     floodfill(60,100,BLUE);
     setcolor(DARKGRAY);
     circle(60,100,22);
     setfillstyle(1,YELLOW);
     floodfill(60,100,DARKGRAY);
     setcolor(LIGHTBLUE);
     outtextxy(45,96,"Sunny");

     getch();
     closegraph();
     return ;
}
Exemplo n.º 14
0
   void menu()
   {
     clrscr();
     setgraph();
     setbkcolor(1);
       for(int i=0;i<635;i+=20)
	 {
	   setcolor(2);
	   setfillstyle(1,2);
	   circle(12+i,10,10);
	   floodfill(12+i,10,2);
	 }
       for(i=0;i<635;i+=20)
	 {
	   setcolor(2);
	   setfillstyle(1,2);
	   circle(12+i,468,10);
	   floodfill(12+i,468,2);
	 }
     settextstyle(8,0,3);
     for(i=420;i>30;i-=3)
	{
	  setcolor(random(15));
	  outtextxy(230,i,"SeLeCtIoN MeNu");
	  delay(40);
	  setcolor(1);
	  outtextxy(230,i,"SeLeCtIoN MeNu");
	}
     setcolor(14);
     outtextxy(230,30,"SeLeCtIoN MeNu");
     line(220,60,440,60);
     for(i=0;i<200;i+=3)
	{
	  setcolor(i);
	  settextstyle(7,0,2);
	  outtextxy(i,110," 1. NEW GAME");
	  outtextxy(i,160," 2. INSTRUCTIONS");
	  outtextxy(i,210," 3. EXIT");
	  delay(40);
	  setcolor(1);
	  outtextxy(i,110," 1. NEW GAME");
	  outtextxy(i,160," 2. INSTRUCTIONS");
	  outtextxy(i,210," 3. EXIT");
	}
     int v;
     for(int h=0;;)
       {
	  for(int i=0;i<635;i+=20)
	    {
	      setcolor(2);
	      setfillstyle(1,2);
	      circle(12+i,10,10);
	      floodfill(12+i,10,2);
	    }
	  for(i=0;i<635;i+=20)
	    {
	      setcolor(2);
	      setfillstyle(1,2);
	      circle(12+i,468,10);
	      floodfill(12+i,468,2);
	    }
     i=200;
     setcolor(15);
     ellipse(310,180,0,360,140,100);
     setfillstyle(1,4);
     floodfill(310,180,15);
     setcolor(15);
     settextstyle(7,0,2);
     outtextxy(i,110," 1. NEW GAME");
     outtextxy(i,160," 2. INSTRUCTIONS");
     outtextxy(i,210," 3. EXIT");
     setcolor(14);
     setfillstyle(1,14);
     circle(180,350,10);
     floodfill(180,350,14);
     setcolor(10);
     setfillstyle(1,10);
     circle(130,200,20);
     floodfill(130,200,10);
     setcolor(6);
     setfillstyle(1,6);
     circle(600,300,15);
     floodfill(600,300,6);
     setcolor(13);
     setfillstyle(1,13);
     circle(30,330,15);
     floodfill(30,330,13);
     setcolor(12);
     setfillstyle(1,12);
     circle(460,350,15);
     floodfill(460,350,12);
     setcolor(13);
     setfillstyle(1,13);
     circle(480,220,20);
     floodfill(480,220,13);
     setcolor(12);
     setfillstyle(1,12);
     circle(50,80,10);
     floodfill(50,80,12);
     setcolor(14);
     setfillstyle(1,14);
     circle(590,80,10);
     floodfill(590,80,14);

     if(h==300)
	v=1;
     else
     if(h==0)
	v=0;
     if(v==1)
	h-=10;
     else
     if(v==0)
	h+=10;
     setcolor(15);
     settextstyle(8,0,2);
     outtextxy(h,400,"Enter Your Choice (1,2 or 3)");
     delay(150);
     setcolor(1);
     settextstyle(8,0,2);
     outtextxy(h,400,"Enter Your Choice (1,2 or 3)");
     if(kbhit())
	{
	   char c=getch();
	   if(c=='1')
	       {
		setcolor(4);
		rectangle(205,320,440,420);
		setcolor(14);
		rectangle(206,321,439,419);
		setcolor(15);
		settextstyle(2,0,6);
		outtextxy(210,340," 1. USER vs COMPUTER");
		outtextxy(210,370," 2.PLAYER 1 vs PLAYER 2");
		p= getch();
		closegraph();
		game();
	       }
	   else
	   if(c=='2')
	       instructions();
	   else
	       exit(0);
	}
     settextstyle(8,0,3);
     setcolor(14);
     outtextxy(230,30,"SeLeCtIoN MeNu");
     line(220,60,440,60);
       }

   }
Exemplo n.º 15
0
void shakil::save2()
{ long int pp[5],cc=0,i1,nm=0,pp1[5]={0};

  FILE *p11,*p22,*p33,*p44,*p1;
  p11=fopen("sav11","r");
  fscanf(p11,"%ld",&pp[0]);
  if(pp[0]==1)
  fscanf(p11,"%ld",&pp1[0]);
  fclose(p11);
  p22=fopen("sav22","r");
  fscanf(p22,"%ld",&pp[1]);
  if(pp[1]==1)
  fscanf(p22,"%ld",&pp1[1]);
  fclose(p22);
  p33=fopen("sav33","r");
  fscanf(p33,"%ld",&pp[2]);
  if(pp[2]==1)
  fscanf(p33,"%ld",&pp1[2]);
  fclose(p33);
  p44=fopen("sav44","r");
  fscanf(p44,"%ld",&pp[3]);
  if(pp[3]==1)
  fscanf(p44,"%ld",&pp1[3]);
  fclose(p44);
  pp[4]=5;
  settextstyle(1,0,1);
  for(i=1;i<=5;i++)
  {setcolor(123);
   rectangle(470,270+i*20+4,580,290+i*20);
    setfillstyle(SOLID_FILL,123);
    floodfill(477,270+i*20+6,123);
   setcolor(RED);
   if(pp[i-1]==0)
    outtextxy(473,270+i*20,"EMPTY");
    if(pp[i-1]==1)
    outtextxy(473,270+i*20,"FULL");
    if(pp[i-1]==5)
    outtextxy(473,270+i*20,"EXIT");

    if(pp1[i-1]!=0)
    { setcolor(RED);
     switch(pp1[i-1])
    {case 2:outtextxy(518,270+i*20,"(2:2)");
	  break;
   case 3:outtextxy(518,270+i*20,"(3:3)");
	  break;
   case 4:outtextxy(518,270+i*20,"(4:4)");
	  break;
   case 5:outtextxy(518,270+i*20,"(5:5)");
	  break;
   case 6:outtextxy(518,270+i*20,"(6:6)");
	  break;
   case 7:outtextxy(518,270+i*20,"(7:7)");
	  break;
   case 8:outtextxy(518,270+i*20,"(8:8)");
	  break;
   case 9:outtextxy(518,270+i*20,"(9:9)");
	  break;
   case 10:outtextxy(518,270+i*20,"(10:10)");
	  break;
   case 11:outtextxy(518,270+i*20,"(11:11)");
	  break;
   }
    }

    }
    while(1)
    {getmousepos(&button,&x,&y);
     if((button & 1)==1)
     {if(x>=470&&x<=580)
      for(i1=1;i1<=5;i1++)
      {tm=270+i1*20+4;tm1=290+i1*20;
      if(y>tm&&y<tm1)
      {
       switch(i1)
       {case 1: if(pp[i1-1]==1)
		{p1=fopen("sav11","r");
		fscanf(p1,"%ld %ld",&m,&n);

		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fscanf(p1," %ld %ld",&res1[i][j],&vm[i][j]);
		fclose(p1);
		x=400/n;y=400/n;
		c12=80/n;
	       for(i=0;i<n;i++)
		{p=50+i*y;q=50;
	       for(j=0;j<n;j++)
	       {xp1[i][j]=q+(j*x);
	       xp2[i][j]=q+((j+1)*x)-c12;
	       yp1[i][j]=p;
	       yp2[i][j]=p+y-c12;}}  }
		break;
	case 2: if(pp[i1-1]==1)
		{p1=fopen("sav22","r");
		fscanf(p1,"%ld %ld",&m,&n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fscanf(p1," %ld %ld",&res1[i][j],&vm[i][j]);
		fclose(p1);
		x=400/n;y=400/n;
		c12=80/n;
		for(i=0;i<n;i++)
		{p=50+i*y;q=50;
		for(j=0;j<n;j++)
		{xp1[i][j]=q+(j*x);
		 xp2[i][j]=q+((j+1)*x)-c12;
		 yp1[i][j]=p;
		yp2[i][j]=p+y-c12;}} }
		break;
	case 3: if(pp[i1-1]==1)
		{p1=fopen("sav33","r");
		fscanf(p1,"%ld %ld",&m,&n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fscanf(p1," %ld %ld",&res1[i][j],&vm[i][j]);
		fclose(p1);
		x=400/n;y=400/n;
		c12=80/n;
		for(i=0;i<n;i++)
	       {p=50+i*y;q=50;
	       for(j=0;j<n;j++)
	      {xp1[i][j]=q+(j*x);
	       xp2[i][j]=q+((j+1)*x)-c12;
	       yp1[i][j]=p;
	       yp2[i][j]=p+y-c12;}}}
		break;
	case 4: if(pp[i1-1]==1)
		{p1=fopen("sav44","r");
		fscanf(p1,"%ld %ld",&m,&n);
		for(i=0;i<n;i++)
		for(j=0;j<n;j++)
		fscanf(p1," %ld %ld",&res1[i][j],&vm[i][j]);
		fclose(p1);
		x=400/n;y=400/n;
		c12=80/n;
		for(i=0;i<n;i++)
	       {p=50+i*y;q=50;
	       for(j=0;j<n;j++)
	       {xp1[i][j]=q+(j*x);
		xp2[i][j]=q+((j+1)*x)-c12;
		yp1[i][j]=p;
		yp2[i][j]=p+y-c12;}}}
		break;
	case 5:nm=5;
	       break;
       }

       cc=5;
       break;
      }}
     }
     if(cc==5)
     break;
    }
  hidemouseptr();
  cleardevice();
  showmouseptr();
  if(nm==0)
  mixed();
}
Exemplo n.º 16
0
void layout()
{
    floodfill(0,0,WHITE);
    setbkcolor(WHITE);
    setcolor(BLACK);
    settextstyle(0,0,1);
    outtextxy(1,55,"credit");
    setbkcolor(BLACK);
    rectangle(1,55,48,65);
    rectangle(1,6,291,52);
    //off
    setfillstyle(SOLID_FILL,BLACK);
    bar(230,75,280,125);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(237,90,"OFF");
    //del,squreroot
    setfillstyle(SOLID_FILL,BLACK);
    bar(175,75,225,125);
    bar(108,75,156,125);
    bar(56,75,104,125);
    bar(4,75,52,125);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(182,90,"DEL");
    line(125,90,142,90);
    line(125,90,123,107);
    line(123,107,120,102);
    outtextxy(128,91,"x");
    outtextxy(71,91,"%");
    outtextxy(20,91,"x");
    settextstyle(2,0,4);
    outtextxy(30,87,"n");


    //9,8,7
    setfillstyle(SOLID_FILL,BLACK);
    bar(4,138,52,188);
    bar(56,138,104,188);
    bar(108,138,156,188);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(20,153,"7");
    outtextxy(72,153,"8");
    outtextxy(124,153,"9");
    //6,5,4
    setfillstyle(SOLID_FILL,BLACK);
    bar(4,192,52,246);
    bar(56,192,104,246);
    bar(108,192,156,246);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(20,207,"4");
    outtextxy(72,207,"5");
    outtextxy(124,207,"6");
    //3,2,1
    setfillstyle(SOLID_FILL,BLACK);
    bar(4,250,52,300);
    bar(56,250,104,300);
    bar(108,250,156,300);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(20,265,"1");
    outtextxy(72,265,"2");
    outtextxy(124,265,"3");
    //0
    setfillstyle(SOLID_FILL,BLACK);
    bar(4,304,52,354);
    bar(56,304,104,354);
    bar(108,304,156,354);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(25,315,".");
    outtextxy(72,319,"0");
    outtextxy(114,319,"ANS");
    //+,-
    setfillstyle(SOLID_FILL,BLACK);
    bar(175,138,225,246);
    bar(175,250,225,300);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(195,183,"+");
    outtextxy(195,265,"-");
    //c,*,/
    setfillstyle(SOLID_FILL,BLACK);
    bar(229,138,279,188);
    bar(229,192,279,246);
    bar(229,250,279,300);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(245,153,"C");
    outtextxy(245,207,"X");
    outtextxy(250,265,"/");
    //=
    setfillstyle(SOLID_FILL,BLACK);
    bar(200,304,250,354);
    setcolor(RED);
    settextstyle(2,0,6);
    outtextxy(218,319,"=");
}
Exemplo n.º 17
0
void drawboard(int startx, int starty, int blocksize)
{
	//Integers declaration
	int iter,iterx,itery;
	//Constant integers decalaration
	int scale = blocksize  * 15;

	setcolor(BLACK);


	//Draw boxes for ludo board:-
	//~~~~~~~~~~~~~~~~~~~~~~~~~
	{
		int locationfromx, locationfromy,
			 locationtox, locationtoy;
		for (iter = 1; iter <=4; iter++)
		{
			switch(iter)
			{
			case 1:
				// For the upper portion
				locationfromx = 6;
				locationfromy = 0;
				locationtox   = 8;
				locationtoy   = 5;
				break;
			case 2:
				// For the left portion
				locationfromx = 0;
				locationfromy = 6;
				locationtox   = 5;
				locationtoy   = 8;
				break;
			case 3:
				// For the right
				locationfromx = 9;
				locationfromy = 6;
				locationtox   = 14;
				locationtoy   = 8;
				break;
			case 4:
				// For the lower portion
				locationfromx = 6;
				locationfromy = 9;
				locationtox   = 8;
				locationtoy   = 14;
				break;
			}

			for(itery = (blocksize*locationfromy) + starty; itery <= (blocksize * locationtoy) + starty; itery = itery + blocksize)
				for(iterx = (blocksize*locationfromx)+startx; iterx <= (blocksize * locationtox) + startx; iterx = iterx + blocksize)
				{
					rectangle (iterx, itery, iterx + blocksize, itery + blocksize);
				}
		}

		// Draw home in middle
		line(startx + blocksize * 6, starty + blocksize * 6, startx + blocksize * 9, starty + blocksize * 9);
		line(startx + blocksize * 9, starty + blocksize * 6, startx + blocksize * 6, starty + blocksize * 9);
		setfillstyle(SOLID_FILL, BLUE);
		floodfill( startx + blocksize * 6.5, starty + blocksize * 7.5, BLACK);
		setfillstyle(SOLID_FILL, GREEN);
		floodfill( startx + blocksize * 7.5, starty + blocksize * 6.5, BLACK);
		setfillstyle(SOLID_FILL, RED);
		floodfill( startx + blocksize * 8.5, starty + blocksize * 7.5, BLACK);
		setfillstyle(SOLID_FILL, YELLOW);
		floodfill( startx + blocksize * 7.5, starty + blocksize * 8.5, BLACK);
		setcolor(BLACK);
		setfillstyle(SOLID_FILL, WHITE);
		fillellipse(startx + blocksize * 7.5, starty + blocksize * 7.5, blocksize, blocksize);
		settextjustify(CENTER_TEXT, CENTER_TEXT);
		outtextxy(startx + blocksize * 7.5, starty + blocksize * 7.5, "Home");
	} //End draw boxes
	
	//Draw blue player's home area
	setcolor(BLUE);
	setfillstyle(CLOSE_DOT_FILL, BLUE);
	bar(startx, starty, startx + blocksize * 6 - 1, starty + blocksize * 6 - 1);
	setfillstyle(SOLID_FILL, WHITE);
	bar(startx + blocksize * 0.5, starty + blocksize * 0.5, startx + blocksize * 5.5,  starty + blocksize * 5.5);
	setfillstyle(SOLID_FILL, BLUE);
	circle(startx + blocksize     + blocksize / 2 , starty + blocksize     + blocksize / 2 , blocksize / 2 );
	circle(startx + blocksize * 4 + blocksize / 2 , starty + blocksize     + blocksize / 2 , blocksize / 2 );
	circle(startx + blocksize     + blocksize / 2 , starty + blocksize * 4 + blocksize / 2 , blocksize / 2 );
	circle(startx + blocksize * 4 + blocksize / 2 , starty + blocksize * 4 + blocksize / 2 , blocksize / 2 );
	line(startx + blocksize * 2, starty + blocksize * 1.5, startx + blocksize * 2  , starty + blocksize * 4.5);
	line(startx + blocksize * 4, starty + blocksize * 1.5, startx + blocksize * 4  , starty + blocksize * 4.5);
	line(startx + blocksize * 1.5, starty + blocksize * 2, startx + blocksize * 4.5, starty + blocksize * 2);
	line(startx + blocksize * 1.5, starty + blocksize * 4, startx + blocksize * 4.5, starty + blocksize * 4);
	floodfill(startx + blocksize * 2.5, starty + blocksize * 2.5, BLUE);

	//Draw green player's home area
	setcolor(GREEN);
	setfillstyle(CLOSE_DOT_FILL, GREEN);
	bar(startx + blocksize * 9 + 1, starty, startx + blocksize * 15, starty + blocksize * 6 - 1);
	setfillstyle(SOLID_FILL, WHITE);
	bar(startx + blocksize * 9.5, starty + blocksize * 0.5, startx + blocksize * 14.5,  starty + blocksize * 5.5);
	setfillstyle(SOLID_FILL, GREEN);
	circle(startx + blocksize * 10.5, starty + blocksize * 1.5, blocksize / 2 );
	circle(startx + blocksize * 13.5, starty + blocksize * 1.5, blocksize / 2 );
	circle(startx + blocksize * 10.5, starty + blocksize * 4.5, blocksize / 2 );
	circle(startx + blocksize * 13.5, starty + blocksize * 4.5, blocksize / 2 );
	line(startx + blocksize * 11, starty + blocksize * 1.5, startx + blocksize * 11  , starty + blocksize * 4.5);
	line(startx + blocksize * 13, starty + blocksize * 1.5, startx + blocksize * 13  , starty + blocksize * 4.5);
	line(startx + blocksize * 10.5, starty + blocksize * 2, startx + blocksize * 13.5, starty + blocksize * 2);
	line(startx + blocksize * 10.5, starty + blocksize * 4, startx + blocksize * 13.5, starty + blocksize * 4);
	floodfill(startx + blocksize * 12, starty + blocksize * 2.5, GREEN);

	//Draw yellow player's home area
	setcolor(BLACK);
	setfillstyle(CLOSE_DOT_FILL, YELLOW);
	bar(startx, starty + blocksize * 9 + 1, startx + blocksize * 6 - 1, starty + blocksize * 15);
	setfillstyle(SOLID_FILL, WHITE);
	bar(startx + blocksize * 0.5, starty + blocksize * 9.5, startx + blocksize * 5.5,  starty + blocksize * 14.5);
	setfillstyle(SOLID_FILL, BLACK);
	circle(startx + blocksize * 1.5, starty + blocksize * 10.5, blocksize / 2 );
	circle(startx + blocksize * 4.5, starty + blocksize * 10.5, blocksize / 2 );
	circle(startx + blocksize * 1.5, starty + blocksize * 13.5 , blocksize / 2 );
	circle(startx + blocksize * 4.5, starty + blocksize * 13.5 , blocksize / 2 );
	line(startx + blocksize * 2, starty + blocksize * 10.5, startx + blocksize * 2  , starty + blocksize * 13.5);
	line(startx + blocksize * 4, starty + blocksize * 10.5, startx + blocksize * 4  , starty + blocksize * 13.5);
	line(startx + blocksize * 1.5, starty + blocksize * 11, startx + blocksize * 4.5, starty + blocksize * 11);
	line(startx + blocksize * 1.5, starty + blocksize * 13, startx + blocksize * 4.5, starty + blocksize * 13);
	floodfill(startx + blocksize * 2.5, starty + blocksize * 11.5, BLACK);

	//Draw red player's home area
	setcolor(RED);
	setfillstyle(CLOSE_DOT_FILL, RED);
	bar(startx + blocksize * 9 + 1, starty + blocksize * 9 + 1, startx + blocksize * 15, starty + blocksize * 15);
	setfillstyle(SOLID_FILL, WHITE);
	bar(startx + blocksize * 9.5, starty + blocksize * 9.5, startx + blocksize * 14.5,  starty + blocksize * 14.5);
	setfillstyle(SOLID_FILL, RED);
	circle(startx + blocksize * 10.5, starty + blocksize * 10.5, blocksize / 2 );
	circle(startx + blocksize * 13.5, starty + blocksize * 10.5, blocksize / 2 );
	circle(startx + blocksize * 10.5, starty + blocksize * 13.5, blocksize / 2 );
	circle(startx + blocksize * 13.5, starty + blocksize * 13.5, blocksize / 2 );
	line(startx + blocksize * 11, starty + blocksize * 10.5, startx + blocksize * 11  , starty + blocksize * 13.5);
	line(startx + blocksize * 13, starty + blocksize * 10.5, startx + blocksize * 13  , starty + blocksize * 13.5);
	line(startx + blocksize * 10.5, starty + blocksize * 11, startx + blocksize * 13.5, starty + blocksize * 11);
	line(startx + blocksize * 10.5, starty + blocksize * 13, startx + blocksize * 13.5, starty + blocksize * 13);
	floodfill(startx + blocksize * 12, starty + blocksize * 11.5, RED);
	
	//Draw stops and home paths on board
	for(iterx = 0; iterx <= 5; iterx++)
		for(itery = 6; itery <= 8; itery++)
			drawblock(iterx,itery);
	for(iterx = 6; iterx <= 8; iterx++)
		for(itery = 0; itery <= 5; itery++)
			drawblock(iterx,itery);
	for(iterx = 9; iterx <= 14; iterx++)
		for(itery = 6; itery <= 8; itery++)
			drawblock(iterx,itery);
	for(iterx = 6; iterx <= 8; iterx++)
		for(itery = 9; itery <= 14; itery++)
			drawblock(iterx,itery);

}
Exemplo n.º 18
0
main()
{
    int driver = DETECT, mode;
    char c;
    int k1[] = { 0, 0, 20, 0, 20, 60, 30, 60, 30, 100, 0, 100, 0, 0 };
    int k2[] = { 40, 0, 50, 0, 50, 60, 60, 60, 60, 100, 30, 100, 30, 60, 40, 60, 40, 0 };
    int k3[] = { 70, 0, 90, 0, 90, 100, 60, 100, 60, 60, 70, 60, 70, 0 };
    int k4[] = { 90, 0, 110, 0, 110, 60, 120, 60, 120, 100, 90, 100, 90, 0 };
    int k5[] = { 130, 0, 140, 0, 140, 60, 150, 60, 150, 100, 120, 100, 120, 60, 130, 60, 130, 0 };
    int k6[] = { 160, 0, 170, 0, 170, 60, 180, 60, 180, 100, 150, 100, 150, 60, 160, 60, 160, 0 };
    int k7[] = { 190, 0, 210, 0, 210, 100, 180, 100, 180, 60, 190, 60, 190, 0 };
    int k8[] = { 210, 0, 230, 0, 230, 60, 240, 60, 240, 100, 210, 100, 210, 0 };
    int k9[] = { 250, 0, 260, 0, 260, 60, 270, 60, 270, 100, 240, 100, 240, 60, 250, 60, 250, 0 };
    int k10[] = { 280, 0, 300, 0, 300, 100, 270, 100, 270, 60, 280, 60, 280, 0 };
    int k11[] = { 300, 0, 330, 0, 330, 100, 300, 100, 300, 0 };
    int k12[] = { 330, 0, 360, 0, 360, 100, 330, 100, 330, 0 };
    initgraph(&driver, &mode, "");
    int maxx = getmaxx();
    int maxy = getmaxy();
    for (long j = 0; j <= 300; j++) {
        putpixel(random(maxx), random(maxy), 4);
        delay(1);
    }
    setfillstyle(SOLID_FILL, BLACK);
    bar(89, 39, 571, 261);
    setlinestyle(SOLID_LINE, 3, 3);
    line(90, 50, 90, 250); //outline
    line(100, 40, 540, 40);
    line(100, 260, 540, 260);
    line(550, 250, 550, 50);
    arc(100, 50, 90, 180, 10);
    arc(100, 250, 180, 270, 10);
    arc(540, 250, 270, 360, 10);
    arc(540, 50, 0, 90, 10);
    circle(200, 90, 35);
    setfillstyle(SOLID_FILL, 9);
    floodfill(200, 90, WHITE);
    circle(482, 95, 42);
    setfillstyle(SOLID_FILL, 3);
    floodfill(482, 95, WHITE);
    setlinestyle(SOLID_LINE, 1, 1);
    rectangle(270, 60, 370, 130);
    setfillstyle(SOLID_FILL, 14);
    floodfill(290, 80, WHITE);
    rectangle(270, 130, 295, 140);
    setfillstyle(SOLID_FILL, 5);
    floodfill(280, 135, WHITE);
    rectangle(295, 130, 320, 140);
    setfillstyle(SOLID_FILL, 5);
    floodfill(300, 135, WHITE);
    rectangle(320, 130, 345, 140);
    setfillstyle(SOLID_FILL, 5);
    floodfill(330, 135, WHITE);
    rectangle(345, 130, 370, 140);
    setfillstyle(SOLID_FILL, 5);
    floodfill(350, 135, WHITE);
    rectangle(120, 60, 145, 70);
    setfillstyle(SOLID_FILL, 1);
    floodfill(130, 65, WHITE);
    rectangle(120, 90, 145, 100);
    setfillstyle(SOLID_FILL, 1);
    floodfill(130, 95, WHITE);
    ellipse(132, 125, 0, 360, 11, 8);
    setfillstyle(SOLID_FILL, RED);
    floodfill(132, 125, WHITE);
    circle(230, 130, 5);
    setfillstyle(SOLID_FILL, RED);
    floodfill(230, 130, WHITE);
    rectangle(387, 60, 427, 75);
    setfillstyle(SOLID_FILL, 10);
    floodfill(395, 70, WHITE);
    rectangle(385, 90, 403, 110);
    setfillstyle(SOLID_FILL, 6);
    floodfill(390, 100, WHITE);
    rectangle(411, 90, 430, 110);
    setfillstyle(SOLID_FILL, 6);
    floodfill(420, 100, WHITE);
    rectangle(387, 120, 427, 135);
    setfillstyle(SOLID_FILL, 10);
    floodfill(395, 130, WHITE);
    rectangle(150, 260, 510, 250);
    setfillstyle(SOLID_FILL, 8);
    floodfill(180, 255, WHITE);
    circle(500, 120, 6);
    setfillstyle(SOLID_FILL, 8);
    floodfill(500, 120, WHITE);
    setviewport(225, 300, 530, 410, 1);
    int poly1[] = { 0, 2, 12, 60, 22, 54, 18, 28, 35, 2, 0, 2 };
    int poly2[] = { 10, 10, 23, 10, 14, 20, 10, 10 };
    int poly3[] = { 50, 0, 60, 2, 60, 45, 50, 42, 50, 0 };
    int poly4[] = { 71, 70, 83, 13, 105, 74, 87, 53, 71, 70 };
    int poly5[] = { 85, 30, 90, 45, 83, 43, 85, 30 };
    int poly6[] = { 110, 53, 120, 2, 130, 57, 148, 0, 135, 84, 132, 84, 118, 29, 110, 53 };
    int poly7[] = { 177, 2, 200, 35, 180, 85, 160, 33, 177, 2 };
    int poly8[] = { 178, 20, 190, 35, 179, 70, 166, 34, 178, 20 };
    drawpoly(6, poly1);
    setfillstyle(SOLID_FILL, RED);
    fillpoly(6, poly1);
    drawpoly(4, poly2);
    setfillstyle(SOLID_FILL, BLACK);
    fillpoly(4, poly2);
    drawpoly(5, poly3);
    setfillstyle(SOLID_FILL, RED);
    fillpoly(5, poly3);
    drawpoly(5, poly4);
    setfillstyle(SOLID_FILL, RED);
    fillpoly(5, poly4);
    drawpoly(4, poly5);
    setfillstyle(SOLID_FILL, BLACK);
    fillpoly(4, poly5);
    drawpoly(8, poly6);
    setfillstyle(SOLID_FILL, RED);
    fillpoly(8, poly6);
    drawpoly(5, poly7);
    setfillstyle(SOLID_FILL, RED);
    fillpoly(5, poly7);
    drawpoly(5, poly8);
    setfillstyle(SOLID_FILL, BLACK);
    fillpoly(5, poly8);
    setviewport(150, 150, 510, 250, 1);
    pnobody();
    c = getch();
    do {
        switch (c) {
        case 'q': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(7, k1);
            pno(261);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k1);
            break;
        }
        case 'w': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(9, k2);
            pno(293);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k2);
            pnobody();
            break;
        }
        case 'e': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(7, k3);
            pno(329);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k3);
            pnobody();
            break;
        }
        case 'r': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(7, k4);
            pno(350);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k4);
            pnobody();
            break;
        }
        case 't': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(9, k5);
            pno(392);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k5);
            pnobody();
            break;
        }
        case 'y': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(9, k6);
            pno(440);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k6);
            pnobody();
            break;
        }
        case 'u': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(7, k7);
            pno(493);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k7);
            pnobody();
            break;
        }
        case 'i': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(7, k8);
            pno(523);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k8);
            pnobody();
            break;
        }
        case 'o': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(9, k9);
            pno(587);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k9);
            pnobody();
            break;
        }
        case 'p': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(7, k10);
            pno(659);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k10);
            pnobody();
            break;
        }
        case '[': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(5, k11);
            pno(698);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(5, k11);
            pnobody();
            break;
        }
        case ']': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(5, k12);
            pno(784);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(5, k12);
            pnobody();
            break;
        }
        case '1': {
            setfillstyle(SOLID_FILL, YELLOW);
            bar(20, 0, 40, 60);
            pno(311);
            setfillstyle(SOLID_FILL, BLACK);
            bar(20, 0, 40, 60);
            pnobody();
            break;
        }
        case '2': {
            setfillstyle(SOLID_FILL, WHITE);
            bar(50, 0, 70, 60);
            pno(370);
            setfillstyle(SOLID_FILL, BLACK);
            bar(50, 0, 70, 60);
            pnobody();
            break;
        }
        case '4': {
            setfillstyle(SOLID_FILL, YELLOW);
            bar(110, 0, 130, 60);
            pno(415);
            setfillstyle(SOLID_FILL, BLACK);
            bar(110, 0, 130, 60);
            pnobody();
            break;
        }
        case '5': {
            setfillstyle(SOLID_FILL, WHITE);
            bar(140, 0, 160, 60);
            pno(466);
            setfillstyle(SOLID_FILL, BLACK);
            bar(140, 0, 160, 60);
            pnobody();
            break;
        }
        case '6': {
            setfillstyle(SOLID_FILL, YELLOW);
            bar(170, 0, 190, 60);
            pno(554);
            setfillstyle(SOLID_FILL, BLACK);
            bar(170, 0, 190, 60);
            pnobody();
            break;
        }
        case '8': {
            setfillstyle(SOLID_FILL, WHITE);
            bar(230, 0, 250, 60);
            pno(662);
            setfillstyle(SOLID_FILL, BLACK);
            bar(230, 0, 250, 60);
            pnobody();
            break;
        }
        case '9': {
            setfillstyle(SOLID_FILL, YELLOW);
            bar(260, 0, 280, 60);
            pno(740);
            setfillstyle(SOLID_FILL, BLACK);
            bar(260, 0, 280, 60);
            pnobody();
            break;
        }
        case 'Q': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(7, k1);
            pno(261);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k1);
            break;
        }
        case 'W': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(9, k2);
            pno(293);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k2);
            pnobody();
            break;
        }
        case 'E': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(7, k3);
            pno(329);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k3);
            pnobody();
            break;
        }
        case 'R': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(7, k4);
            pno(350);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k4);
            pnobody();
            break;
        }
        case 'T': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(9, k5);
            pno(392);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k5);
            pnobody();
            break;
        }
        case 'Y': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(9, k6);
            pno(440);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k6);
            pnobody();
            break;
        }
        case 'U': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(7, k7);
            pno(493);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k7);
            pnobody();
            break;
        }
        case 'I': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(7, k8);
            pno(523);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k8);
            pnobody();
            break;
        }
        case 'O': {
            setfillstyle(SOLID_FILL, GREEN);
            fillpoly(9, k9);
            pno(587);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(9, k9);
            pnobody();
            break;
        }
        case 'P': {
            setfillstyle(SOLID_FILL, RED);
            fillpoly(7, k10);
            pno(659);
            setfillstyle(SOLID_FILL, BLUE);
            fillpoly(7, k10);
            pnobody();
            break;
        }
        case ' ': {
            break;
        }
        }
        c = getch();
    } while (c != ' ');
    setviewport(0, 0, maxx, maxy, 1);
    cleardevice();
    for (j = 0; j <= 1100; j++) {
        putpixel(random(maxx), random(maxy), 4);
        delay(1);
    }
    setcolor(4);
    outtextxy(270, 150, "C R E D I T S");
    for (int i = 0; i <= 3; i++) {
        outtextxy(260, 155 + i, "_______________");
    }
    delay(600);
    outtextxy(150, 200, " #Suvojit Manna:Concept & Design,Core Programing");
    outtextxy(160, 205, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ");
    delay(600);
    outtextxy(165, 250, " #Prangshu Shyam:Graphical Assisstance");
    outtextxy(180, 255, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ");
    delay(600);
    outtextxy(200, 300, " #Sourav Kundu:Final Compilation");
    outtextxy(210, 305, "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ");
    getch();
    return 0;
}
Exemplo n.º 19
0
void game(int mx,int my)
{
        cleardevice();
        int x,y,cl=0,i,j,ctr=0,points=0,lives=3,dt=100;
        int *ycoord,*bomby;
        int delaytime[20];
        int randomcolor;

        int *xcoord,*bombx,numctr=0,playtime=0;
        int nob=0,bombctr=0,temp,selbomb;

        callmouse();
        setlimits(23,mx-23,23,my-23);
        delay(100);

        // ASSIGN THE SPEED
        for(i=0;i<10;i++){delaytime[i]=i+10;}

        // ALOCATE MEMORY FOR COORDINATES

        if((ycoord=(int *)malloc(10))==NULL||(xcoord=(int *)malloc(10))==NULL||(bomby=(int *)malloc(10))==NULL||(bombx=(int *)malloc(10))==NULL)
        {
                cout<<"\nMEMORY ALLOCATION ERROR!";
                getch();
                exit(0);

        }

        randomize();
        outline(mx,my);

//THE GAME BEGINS

        int start=clock(),end;
        for(i=0;i<lives;i++)
        {
                setcolor(WHITE);
                circle((mx-200)+(i*20),my-10,6);
                setfillstyle(SOLID_FILL,RED);
                floodfill((mx-200)+(i*20),my-10,WHITE);
        }

        for(;;)
        {



        //      ASSIGN COORDINATES TO BOMBS
                selbomb=random(10);
                if( (selbomb%7)==0 && nob<=3)
                {
                        *(bombx+bombctr)=50;
                        *(bomby+bombctr)=random(my-100)+50;
                        bombctr++;
                        nob++;
                }


        //      ASSIGN COORDINATES TO BUBLES
                if(numctr<3)
                {
                        *(xcoord+ctr)=48;
                        *(ycoord+ctr)=random(my-100)+48;
                        numctr++;
                        ctr++;
                }
        //      DROP THE BOMBS
                for(i=0;i<nob;i++)
                {
                        setcolor(WHITE);
                        circle(*(bombx+i),*(bomby+i),22);
                }

        //      CREATE BUBLES
                for(i=0;i<numctr;i++)
                {
                        randomcolor=random(5)+1;
                        setcolor(randomcolor);
                        circle(*(xcoord+i),*(ycoord+i),20);

                }
       //       MOUSE
                altermouse(x,y,cl);
                delay(dt);

       //       CHECK WHAT HAPPENED WITH BUBLES
                temp=numctr;
                for(i=0;i<temp;i++)
                {
                //      CHECK IF BUBLES WERE HIT
                        if(x < *(xcoord+i)+20 && x > *(xcoord+i)-20 && y< *(ycoord+i)+20 && y>*(ycoord+i)-20)
                        {
                                points+=10;
                                numctr--;
                                ctr=i;
                                cleardevice();
                                outline(mx,my);
                                for(j=0;j<lives;j++)
                                {
                                        setcolor(WHITE);
                                        circle((mx-200)+(j*20),my-10,6);
                                        setfillstyle(SOLID_FILL,RED);
                                        floodfill((mx-200)+(j*20),my-10,WHITE);
                                }

                        }
                //      DE-CREATE THE BUBLES
                        setcolor(BLACK);
                        circle(*(xcoord+i),*(ycoord+i),20);

                //      LET THE BUBLES MOVE
                        *(xcoord+i)+=delaytime[i];

                //      CHECK FOR PLAYER'S DEATH
                        if(xcoord[i]>=mx-48)
                        {
                                numctr--;
                                lives--;

                                if(lives==0){goto again;}
                                for(j=0;j<lives+1;j++)
                                {
                                        setcolor(BLUE);
                                        circle((mx-200)+(i*20),my-10,6);
                                        setfillstyle(SOLID_FILL,BLUE);
                                        floodfill((mx-200)+(j*20),my-10,BLUE);
                                }
                                for(j=0;j<lives;j++)
                                {
                                        setcolor(WHITE);
                                        circle((mx-200)+(j*20),my-10,6);
                                        setfillstyle(SOLID_FILL,RED);
                                        floodfill((mx-200)+(j*20),my-10,WHITE);
                                }
                                ctr=i;
                        }


                }

       //       CHECK WHAT HAPPENED WITH THE BOMB
                temp=nob;
                for(i=0;i<temp;i++)
                {
                //      CHECK FOR PLAYERS DEATH AND THE END OF GAME
                        if(x < *(bombx+i)+22 && x > *(bombx+i)-22 && y< *(bomby+i)+22 && y>*(bomby+i)-22)
                        {
                                goto again;

                        }
                //      DE-CREATE THE BOMBS
                        setcolor(BLACK);
                        circle(*(bombx+i),*(bomby+i),22);
                //      LET THE BOMBS MOVE
                        *(bombx+i)+=delaytime[i];
                //      CHECK FOR THE BOMBS DEATH
                        if(*(bombx+i)>=mx-45)
                        {
                                bombctr=i;
                                nob--;
                                *(bombx+bombctr)=48;
                                *(bomby+bombctr)=random(my-100)+50;
                                nob++;
                        }

                }
                end=clock();
                playtime=ceill((end-start)/CLK_TCK);
                if(playtime>10)
                {
                        dt-=10;
                        start=clock();
                }

        }
//      THIS IS THE END :

        again:
        cleardevice();
        outline(mx,my);
        endgame(points,mx,my);
        readscore(points);
        hidemouse();
        delete ycoord,xcoord;
        menu(mx,my);
}
Exemplo n.º 20
0
partlist *getParticles(matrix *mat){
	int i,j;
	int id_counter=0;
	int width,height;
	
	partlist *plist;
	if((plist = calloc(1,sizeof(partlist)))==NULL){
		fprintf(stderr, "ident.c: getParticles(): Out of memory error.\n");
		exit(1);
	}

	width=mat->width;
	height=mat->height;
	
	for(i=0; i<width; i++){
		for(j=0; j<height; j++){

			if(mat->vals[i][j] == 0){
				continue;
			}

			particle *part;
			
			part = floodfill(mat,getid(&id_counter),i,j);
			find_center(part);
			find_radius(part);
#ifndef USE_RADIUS_THRESH
			if(part->size > MAX_PART_SIZE){			//This if statement removes any particles that are too large or too small.
				freeParticle(part);
				continue;
			}else if(part->size < MIN_PART_SIZE){
				freeParticle(part);
				continue;
			}
#endif
			
			
			
			
#ifdef	USE_RADIUS_THRESH
			
			if(part->radius > RAD_MAX){
				freeParticle(part);
				continue;
			}else if(part->radius < RAD_MIN){
				freeParticle(part);
				continue;
			}
#endif

			
			
			else if(part->x > mat->width-6){
				freeParticle(part);
				continue;
			}else if(part->x < 5){
				freeParticle(part);
				continue;
			}else if(part->y > mat->height-6){
				freeParticle(part);
				continue;
			}else if(part->y < 5){
				freeParticle(part);
				continue;
			}else{
				pushParticle(plist,part);
			}		
			
			
		}
	}
	return plist;
}
Exemplo n.º 21
0
void verify_level_graph	(LPCSTR name, bool verbose)
{
	Msg				("Verifying level %s",name);
	Phase			("Verifying level graph");
	Progress		(0.f);
	CLevelGraph		*level_graph = xr_new<CLevelGraph>(name);
	if (!level_graph->header().vertex_count()) {
		Progress	(1.f);
		Msg			("Level graph is empty!");
		xr_delete	(level_graph);
		return;
	}

	if (!verify_invalid_links(*level_graph)) {
		Progress	(1.f);
		Msg			("AI map is CORRUPTED : REGENERATE AI-MAP");
		xr_delete	(level_graph);
		return;
	}

	stack_storage	= (CLevelGraph::CVertex**)xr_malloc(level_graph->header().vertex_count()*sizeof(CLevelGraph::CVertex*));

	xr_vector<bool>	marks;

	xr_vector<u32>	single_links;
	single_links.reserve(level_graph->header().vertex_count());
	Progress		(0.05f);

	for (u32 i=0, n=level_graph->header().vertex_count(); i<n; ++i) {
		CLevelGraph::const_iterator	I, E;
		CLevelGraph::CVertex		*vertex = level_graph->vertex(i);
		level_graph->begin			(vertex,I,E);
		for ( ; I != E; ++I) {
			u32						neighbour_vertex_id = level_graph->value(vertex,I);
			if (level_graph->valid_vertex_id(neighbour_vertex_id) && single_link(*level_graph,neighbour_vertex_id,i,(I + 2)%4)) {
				single_links.push_back	(neighbour_vertex_id);
			}
		}
		Progress					(0.05f + 0.05f*float(i)/float(n));
	}

	bool							no_single_links = single_links.empty();
	Progress						(0.1f);
	if (single_links.empty())
		single_links.push_back		(0);

	{
		sort						(single_links.begin(),single_links.end());
		xr_vector<u32>::iterator	I = unique(single_links.begin(),single_links.end());
		single_links.erase			(I,single_links.end());
	}

	if (!no_single_links) {
		if (verbose) {
			xr_vector<u32>::const_iterator	I = single_links.begin();
			xr_vector<u32>::const_iterator	E = single_links.end();
			for ( ; I != E; ++I)
				Msg					("Vertex %d[%f][%f][%f] is single linked!",*I,VPUSH(level_graph->vertex_position(*I)));
		}
		Msg							("There are %d single linked nodes!",single_links.size());
	}

	Progress						(0.15f);
	bool							valid = true;
	xr_vector<u32>::const_iterator	I = single_links.begin();
	xr_vector<u32>::const_iterator	E = single_links.end();
	for (u32 i=0, n = single_links.size(); I != E; ++I, ++i) {
		marks.assign	(level_graph->header().vertex_count(),false);
		floodfill		(*level_graph,marks,*I);
		xr_vector<bool>::const_iterator	II = marks.begin(), BB = II;
		xr_vector<bool>::const_iterator	EE = marks.end();
		for ( ; II != EE; ++II)
			if (!*II) {
				valid	= false;
				Msg		("AI-map is NOT valid :\nNode \n%6d[%f][%f][%f]\ncannot be reached from the node\n%6d[%f][%f][%f]\n",u32(II - BB),VPUSH(level_graph->vertex_position(u32(II - BB))),*I,VPUSH(level_graph->vertex_position(*I)));
				break;
			}

		if (!valid)
			break;
		Progress		(0.15f + 0.85f*float(i)/float(n));
	}

	xr_free			(stack_storage);
	xr_delete		(level_graph);
	Progress		(1.f);
	if (valid)
		Msg			("AI-map is valid!");

	Msg				("Verifying level %s completed",name);
}
Exemplo n.º 22
0
int main()
{
   int gd=DETECT,gm;
   initgraph(&gd,&gm,"");
int c=12;
setbkcolor(0);
//setlinestyle(0,1,2);
int t;
while(1)
{
settextstyle(2,0,5);
outtextxy(100,10,"Press L,H ,T,P");
outtextxy(100,30,"Press 1 for Quit");
as:
setcolor(13);
ellipse(380,127,20,152,130,35);
//////////////////////////////rear//////////////////////////

line(490,109,560,142);
line(560,142,569,142);
line(569,142,582,102);
line(582,102,620,92);
line(593,132,617,125);

line(617,124,627,96);
line(620,92,628,97);

line(472,86,602,96);
line(501,113,575,121);
line(443,77,475,80);

line(443,77,432,93);
line(475,80,472,85);
//setcolor(4);
   line(593,132,593,137);
   line(593,137,600,141);
   line(600,141,600,185);
   line(600,185,608,192);
   line(608,192,608,234);
   line(608,234,586,253);
    line(586,253,577,248);

/////////////////////////           mirror
   line(263,112,363,127);
      line(193,160,263,112);
   line(193,160,220,170);
      line(220,170,280,180);
      line(280,180,320,185);
      line(320,185,363,127);
////////////////////////////////sidemirror
line(340,194,460,169);
 line(460,169,519,152);

ellipse(512,144,300,30,10,10);
ellipse(467,143,28,100,50,30);
line(510,128,521,138);
line(435,116,440,171);

//   setcolor(4);           
////////////////////////////////////////cont//
   line(339,194,372,144);
//    line(372,140,386,128);
ellipse(454,208,87,123,128,95);
line(372,144,384,128);
   int b,x,y;
////////////////////////lower
line(365,298,524,264);
line(365,298,330,310);
line(330,310,323,310);


///////////////////////////////bumper
ellipse(162,221,135,190,90,40);
line(96,193,140,174);
line(140,174,160,168);
line(160,168,192,161);

//////////////////////front
ellipse(75,246,95,190,18,18);
line(57,251,57,286);
//setcolor(4);
ellipse(181,178,232,263,200,137);
ellipse(195,180,256,286,200,137);


ellipse(191,171,228,247,200,100);
ellipse(231,198,234,275,200,80);

//setcolor(9);
//ellipse(195,170,256,286,200,137);
//setcolor(12);

ellipse(196,167,228,246,200,90);
ellipse(231,184,234,276,200,80);


ellipse(191,200,228,246,200,90);
ellipse(228,218,234,276,200,80);

ellipse(258,268,180,220,200,40);
ellipse(178,296,244,355,16,10);

ellipse(238,249,227,250,200,60);


/////////////wheel1
ellipse(302,281,320,77,26,45);
ellipse(290,277,65,162,40,45);
ellipse(278,288,144,212,31,45);

/////////////wheel2
//setcolor(5);
ellipse(302+260,229,328,87,26,45);
ellipse(290+280-7,277-50+2,90,162,40,45);
ellipse(278+270,288-50,144,215,27,45);
 b=0;
int v=0;

/////////
ellipse(302+250+v,227+b,295,90,29,41);
ellipse(302+234+v,231+b,245,306,50,40);
//setlinestyle(3,0,3);
ellipse(302+248+v,229+b,0,360,21,30);

ellipse(302+247+v,229+b,0,360,8,10);
setfillstyle(6,11);
floodfill(302+248+v,230+b,13);
line(546,201,546,257);
line(554,201,554,257);
setcolor(4);

line(546+v,201+b,546+v,220+b);
line(551+v,201+b-2,551+v,220+b);

line(546+v,238+b,546+v,257+b);
line(551+v,238+b+2,551+v,257+b+2);


line(530+v,225+b,541+v,225+b);
line(530+v,230+b,541+v,230);

line(557+v,225+b,570+v,225+b);
line(557+v,230+b,570+v,230+b);



line(563+v,206+b,552+v,222+b);
line(534+v,246+b,543+v,232+b);

line(566+v,210+b,556+v,223+b);
line(536+v,250+b,544+v,238+b);

line(536+v,207+b,546+v,222+b);
line(532+v,213+b,542+v,224+b);

line(556+v,235+b,566+v,247+b);
line(551+v,237+b,563+v,253+b);



////////////////////////////////////////////////////
v=-260;
b=56;
ellipse(302+233+v,221+b,260,60,49,51);
ellipse(302+234+v,231+b,245,306,50,40);
setlinestyle(3,0,3);
ellipse(302+243+v,224+b,0,360,28,35);
  line(249,328,269,328);
ellipse(300+245+v,223+b,0,360,10,12);

ellipse(285+249+v,239+b,210,260,30,33);
floodfill(285+258+v,230+b,12);
b=45;
v=v-4;
line(546+v,201+b,546+v,220+b+2);
line(551+v,201+b,551+v,220+b+2);
b=b+8;
line(546+v,238+b,546+v,257+b+4);
line(551+v,238+b,551+v,257+b+4);
v=v-2;
line(530+v-6,225+b,541+v,225+b);
line(530+v-6,230+b,541+v,230+b);
v=v+5;
line(557+v,225+b,570+v+3,225+b);
line(557+v-1,230+b,570+v+3,230+b);


b=b-5;
v=v-5;
line(565+v+3,206+b,552+v+4,222+b-2);
b=b+15;

line(534+v,246+b,543+v+3,232+b-5);
b=b-10;
line(566+v+7,210+b-5,556+v+4,220+b);
line(536+v-5,250+b,544+v-2,238+b-4);


line(536+v,207+b-8,545+v,222+b-5);
line(531+v,212+b-8,542+v,224+b-2);

line(556+v,235+b,566+v+3,247+b+5);
line(551+v,237+b,563+v+2,253+b+3);

///////////////////lights
ellipse(199,250,144,345,18,8);
line(185,245,206,230);
setcolor(4);
ellipse(223,234,340,110,8,5);
line(230,237,217,252);
line(206,230,220,229);
setfillstyle(1,4);

floodfill(200,240,12);

/////////////////////////////////////
line(90,223,152,236);
line(152,236,137,254);
line(90,223,90,242);

setfillstyle(10,9);
floodfill(91,230,14);
ellipse(240,270,104,136,100,60);
ellipse(185,237,120,160,100,60);
ellipse(80,221,357,134,10,10);

line(152,236,168,228);
///////////////////////////////////////////////
line(435,116,440,171);
//////////////////////////////////////////hp
line(134,185,220,210);
line(134,185,196,160);
line(214,212,318,185);
/////////////////////////////////////////////////light

setcolor(14);
ellipse(166,247,99,330,8,8);
ellipse(171,243,310,129,7,7);
putpixel(174,250,13);
putpixel(173,251,13);
putpixel(164,239,13);
putpixel(165,238,13);

/////////////////////////////////////////road/////////////////////
setcolor(13);
line(1,430,639,300);
line(1,445,639,315);

line(1,210,93,194);
line(1,195,194,158);

line(1,170,639,71);
line(1,170,229,135);
line(520,90,639,71);
line(478,86,639,56);

   int c=0;

   line(10,194+c,10,208+c);
line(40,189+c,40,204+c);
line(70,183+c,70,198+c);
line(100,176+c,100,190+c);
line(130,170+c,130,177+c);
line(160,166+c,160,168+c);
line(190,160+c,190,161+c);

 line(190+330,78+c,190+330,89+c);

line(190+360,72+c,190+360,85+c);
line(190+390,67+c,190+390,81+c);
line(190+420,62+c,190+420,76+c);
line(190+449,57+c,190+449,71+c);



   c=236;

line(10,192+c,10,208+c);
line(40,189+c-2,40,204+c-3);
line(70,183+c-3,70,198+c-3);
line(100,176+c-2,100,190+c-2);
line(130,170+c-2,130,177+c+5);
line(160,166+c-3,160,168+c+8);
line(190,160+c-4,190,161+c+9);

line(190+30,156+c-5,190+30,170+c-5);


line(190+30+30,156+c-12,190+30+30,170+c-12);

line(190+90,156+c-18,190+90,170+c-17);

line(190+120,156+c-25,190+120,170+c-25);

line(190+150,156+c-30,190+150,170+c-30);

line(190+180,156+c-37,190+180,170+c-36);


line(190+210,156+c-42,190+210,170+c-42);


line(190+240,156+c-48,190+240,170+c-48);


line(190+270,156+c-55,190+270,170+c-54);


line(190+300,156+c-61,190+300,170+c-61);



 line(190+330,78+c+10,190+330,89+c+13);

line(190+360,72+c+11,190+360,85+c+13);
line(190+390,67+c+10,190+390,81+c+10);
line(190+420,62+c+8,190+420,76+c+10);
line(190+449,57+c+8,190+449,71+c+8);




/////////////////road

setcolor(12);          /////////////////////////////1

line(1,310,25,306);
line(6,318,30,315);
line(1,310,6,318);
line(25,306,30,314);
int k,m;
k=13*45+19;
m=16*(-8);
						    //2
setcolor(12);

line(605,310-128,629,306-128);
line(610,318-128,634,315-128);
line(605,310-128,610,318-128);
line(629,306-128,634,314-128);

setcolor(12);    //////////////////////////////////3
k=45;
m=-8;
line(46,302,70,298);
line(51,310,75,307);
line(46,302,51,310);
line(70,298,75,306);


setfillstyle(1,0);
floodfill(64,303,12);

setfillstyle(1,14);
floodfill(14,314,12);
floodfill(617,183,12);

setfillstyle(1,0);
floodfill(14,314,12);
floodfill(617,183,12);

setfillstyle(1,14);
floodfill(64,303,12);

t=getch();
if(t=='1')
exit(0);
if(t=='h')
{
//sound(710);
delay(50);
//nosound();
break;
}
if(t=='t')
{
while(!kbhit())  {
setfillstyle(1,0);
floodfill(536,213,13);
floodfill(563,213,13);
floodfill(561,244,13);
floodfill(538,244,13);
floodfill(274,295,13);
floodfill(294,295,13);
floodfill(274,265,13);
floodfill(294,265,13);
floodfill(548,250,13);
floodfill(548,214,13);
floodfill(533,228,13);
floodfill(563,228,13);
floodfill(262,281,13);
floodfill(308,281,13);
floodfill(284,251,13);
floodfill(284,295,13);

setfillstyle(1,12);

floodfill(200,250,13);
delay(10);
setfillstyle(1,11);

 floodfill(170,250,13);
 floodfill(80,230,13);


 }

setfillstyle(1,0);

floodfill(200,250,13);
delay(10);
setfillstyle(1,11);

 floodfill(170,250,13);
 floodfill(80,230,13);

	}


if(t=='l')
{
while(!kbhit())
{

delay(120);
setfillstyle(6,0);         //////////////////////////ty
floodfill(536,213,13);
floodfill(563,213,13);
floodfill(561,244,13);
floodfill(538,244,13);
floodfill(274,295,13);
floodfill(294,295,13);
floodfill(274,265,13);
floodfill(294,265,13);

setfillstyle(1,0);
floodfill(64,303,12);

///////////////////////////////////road

setfillstyle(9,0);       /////////////////////color
floodfill(81-40+5,419+7,13);
floodfill(151-40,409+7,13);
floodfill(211-40,397+7,13);
floodfill(271-40,380+7,13);
floodfill(331-40,368+7,13);
floodfill(396-40,355+7,13);
floodfill(450-40,345+7,13);
floodfill(510-40,335+7,13);
floodfill(570-40,325+7,13);
floodfill(630-40,312+7,13);


//////////////////////
floodfill(50,197,13);
floodfill(110,177,13);
floodfill(166,165,13);
floodfill(527,86,13);
floodfill(587,71,13);




setfillstyle(6,14); //////////////////////////ty
floodfill(548,250,13);
floodfill(548,214,13);
floodfill(533,228,13);
floodfill(563,228,13);
floodfill(262,281,13);
floodfill(308,281,13);
floodfill(284,251,13);
floodfill(284,295,13);
////////////////////////////////////////road

setfillstyle(9,10);///////////////////////////////////color
floodfill(19,429,13);
floodfill(81,419,13);
floodfill(151,409,13);
floodfill(211,397,13);
floodfill(271,380,13);
floodfill(331,368,13);
floodfill(396,355,13);
floodfill(450,345,13);
floodfill(510,335,13);
floodfill(570,325,13);
floodfill(630,312,13);
//////////////////////////////////////
floodfill(20,197,13);
floodfill(80,187,13);
floodfill(133,174,13);
floodfill(517,86,13);
floodfill(557,81,13);
floodfill(627,70,13);

setfillstyle(1,14);
floodfill(14,314,12);
floodfill(617,183,12);

///////////////////////////////////////
setfillstyle(10,4);
floodfill(302+248,230,13);
floodfill(302+248+v,230+b,13);
///light
setfillstyle(6,11);                             ///////////

floodfill(200,250,13);

floodfill(170,250,13);
 floodfill(80,230,13);

delay(120);

setfillstyle(6,0);/////////////////////ty
floodfill(548,250,13);
floodfill(548,214,13);
floodfill(533,228,13);
floodfill(563,228,13);
floodfill(262,281,13);
floodfill(308,281,13);
floodfill(284,251,13);
floodfill(284,295,13);
/////////////////////////////////////road
setfillstyle(9,0);      ///////////////color

floodfill(19,429,13);
floodfill(81,419,13);
floodfill(151,409,13);
floodfill(211,397,13);
floodfill(271,380,13);
floodfill(331,368,13);
floodfill(396,355,13);
floodfill(450,345,13);
floodfill(510,335,13);
floodfill(570,325,13);
floodfill(630,312,13);
///////////////////////////////////////////////////////
floodfill(20,197,13);
floodfill(80,187,13);
floodfill(133,174,13);
floodfill(517,86,13);
floodfill(557,81,13);
floodfill(627,70,13);
/////////////////////////////
setfillstyle(1,0);
floodfill(14,314,12);
floodfill(617,183,12);

setfillstyle(6,10);            /////////////ty

floodfill(536,213,13);
floodfill(563,213,13);
floodfill(561,244,13);
floodfill(538,244,13);
floodfill(274,295,13);
floodfill(294,295,13);
floodfill(274,265,13);
floodfill(294,265,13);
////////////////////////////////////////////////road
setfillstyle(9,14);/////////////////////////////////////////color
floodfill(81-40+5,419+7,13);
floodfill(151-40,409+7,13);
floodfill(211-40,397+7,13);
floodfill(271-40,380+7,13);
floodfill(331-40,368+7,13);
floodfill(396-40,355+7,13);
floodfill(450-40,345+7,13);
floodfill(510-40,335+7,13);
floodfill(570-40,325+7,13);
floodfill(630-40,312+7,13);
/////////////////////////////////////////

floodfill(50,197,13);
floodfill(110,177,13);
floodfill(166,165,13);
floodfill(527,86,13);
floodfill(587,71,13);
setfillstyle(1,14);
floodfill(64,303,12);

setfillstyle(9,4);
floodfill(302+248,230,13);
floodfill(302+248+v,230+b,13);

delay(20);
setfillstyle(1,14);

floodfill(200,250,13);

floodfill(170,250,13);
 floodfill(80,230,13);

 delay(20);
setfillstyle(1,0);

floodfill(200,250,13);

floodfill(170,250,13);
 floodfill(80,230,13);




}          }




if(t=='p')
{
int n=0;
while(!kbhit())
{
if(n<=60)
n++;
setcolor(0);
rectangle(1+1,-10,90-1,-12+n);
delay(14);

setcolor(9);
rectangle(1,-10,90,-10+n);
if(n==60)
{

outtextxy(10,10,"L-LIGHTS");
outtextxy(10,20,"H-HORN");
outtextxy(10,30,"T-AllOY");
 delay(400);
 }


}
setcolor(0);
rectangle(1,-10,90,-10+n);
rectangle(1,-10,90,-11+n);
outtextxy(10,10,"L-LIGHTS");
outtextxy(10,20,"H-HORN");
outtextxy(10,30,"T-AllOY");

}

}



circle(300,100,3);

//nosound();

getch();
}
///////////////////////////////// GRAPHICS FUNCTIONS /////////////////////////////////////////////
void draw()
{
initwindow(900,900);
setcolor(GREEN);
rectangle(400,150,650,650);// Outer Rectangle for Multimeter
setfillstyle(SOLID_FILL,YELLOW);
floodfill(500,500,GREEN);
rectangle(405,155,645,645);// Inner Rectangle for Multimeter
setfillstyle(SOLID_FILL,DARKGRAY);
floodfill(500,500,GREEN);
rectangle(410,160,640,310);//Rectangle for LED Display
setfillstyle(SOLID_FILL,BLACK);
floodfill(500,200,GREEN);
circle(525,500,75);//Circle for Rotary Dial
setfillstyle(SOLID_FILL,RED);
floodfill(525,500,GREEN);
rectangle(523,425,528,500);//Rectangle for Rotary Dial
setfillstyle(XHATCH_FILL,RED);
floodfill(525,450,GREEN);
rectangle(410,330,450,350);//Rectangle for Row 1 Button 1 (POWER Button)
setfillstyle(SOLID_FILL,YELLOW);
floodfill(420,340,GREEN);
rectangle(470,330,510,350);//Rectangle for Row 1 Button 2
setfillstyle(SOLID_FILL,RED);
floodfill(480,340,GREEN);
rectangle(530,330,570,350);//Rectangle for Row 1 Button 3
setfillstyle(SOLID_FILL,RED);
floodfill(540,340,GREEN);
rectangle(590,330,630,350);//Rectangle for Row 1 Button 4
setfillstyle(SOLID_FILL,RED);
floodfill(610,340,GREEN);
circle(430,390,10);
setfillstyle(SOLID_FILL,RED);
floodfill(430,390,GREEN);
rectangle(470,380,510,400);//Rectangle for Row 2 Button 1
setfillstyle(SOLID_FILL,RED);
floodfill(480,390,GREEN);
rectangle(530,380,570,400);//Rectangle for Row 2 Button 2
setfillstyle(SOLID_FILL,RED);
floodfill(540,390,GREEN);
rectangle(590,380,630,400);//Rectangle for Row 2 Button 3
setfillstyle(SOLID_FILL,RED);
floodfill(610,390,GREEN);
circle(430,620,10);//Circle for Port 1
setfillstyle(SOLID_FILL,RED);
floodfill(430,620,GREEN);
circle(493,620,10);//Circle for Port 2
setfillstyle(SOLID_FILL,RED);
floodfill(493,620,GREEN);
circle(556,620,10);//Circle for Port 3
setfillstyle(CLOSE_DOT_FILL,RED);
floodfill(556,620,GREEN);
circle(619,620,10);//Circle for Port 4
setfillstyle(SOLID_FILL,RED);
floodfill(619,620,GREEN);
while (!kbhit())
{
delay(200);
if (GetKeyState(VK_LBUTTON))
{
// line(410,250,640,250);
settextstyle(1,0,6);//Display Reading upon Left Mouse Button Click
outtextxy(430,200,"250.0");
}
if (GetKeyState(VK_SPACE))
{
setfillstyle(SOLID_FILL,BLUE);
floodfill(430,390,GREEN);
delay(2000);
}
}
closegraph();
}
Exemplo n.º 24
0
int MenuProvas  ( void )
   {
   static	char *Opcoes[NUMOPC] = {
					"      POS SIMPLES      ",
					"    BRONCO-DILATACAO   ",
					"   BRONCO-PROVOCACAO   ",
					"ESPIROMETRIA DE ESFORCO",
					"        RETORNAR       "
				       };

   int  cont = 0, Lin[NUMOPC], alt;
   int               i, corf, corb;


   Lin[0] =  5;
   Lin[1] = 25;
   Lin[2] = 45;
   Lin[3] = 65;
   Lin[4] = 85;

   AtivaJanelaGrafica(MENU_2,0);
   clearviewport ();
   setcolor (bea_color[14]);
   getviewsettings(&vp);
   clearviewport();

   alt = CharH;

   for ( i = 0; i < NUMOPC; i++ )
      {
      setviewport( vp.left , vp.top + DELTA_Y(Lin[i]) - 1,
		   vp.right, vp.top + DELTA_Y(Lin[i]) + 1 + alt, 1);
      clearviewport();

      if ( cont == i )
	 {
	 corb = bea_color[14];
	 corf = bea_color[ 0];
	 }
      else
	 {
	 corb = bea_color[ 0];
	 corf = bea_color[14];
	 }

      setfillstyle(1, corb);
      floodfill(1,1,1);
      setcolor(corf);
      outtextxy(  DELTA_X(50) - textwidth(Opcoes[i])/2, 2, Opcoes[i]);

      }

   do {
      LimpaBufferTeclado();
      sc.c = LeTeclado();
      if (sc.ch[0] == 0)
	 if (sc.ch[1]==72 || sc.ch[1]==80)
	    {
	    setviewport( vp.left , vp.top + DELTA_Y(Lin[cont]) - 1,
			 vp.right, vp.top + DELTA_Y(Lin[cont]) + 1 + alt, 1);

	    clearviewport();

	    setcolor(bea_color[14]);

	    outtextxy(  DELTA_X(50) - textwidth(Opcoes[cont])/2, 2, Opcoes[cont]);

	    if (sc.ch[1]==72)
	       {
	       if (--cont < 0)  cont = NUMOPC - 1;
	       }
	    else
	       {
	       cont = (cont + 1) % NUMOPC;
	       }

	    setviewport( vp.left , vp.top + DELTA_Y(Lin[cont]) - 1,
			 vp.right, vp.top + DELTA_Y(Lin[cont]) + 1 + alt, 1);

	    clearviewport();
	    setfillstyle(1, bea_color[14]);
	    floodfill(1,1,1);
	    setcolor(bea_color[0]);
	    outtextxy(  DELTA_X(50) - textwidth(Opcoes[cont])/2, 2, Opcoes[cont]);
	    }

      } while(sc.ch[0] != ENTER);

   setviewport(vp.left,vp.top,vp.right,vp.bottom,1);

   return(cont);
   }  /* End of MenuProvas () */
Exemplo n.º 25
0
void Graphics::FloodFill(int x, int y, color_t color)
{
	floodfill(_alBitmap, x, y, color);
}
Exemplo n.º 26
0
void rysuj_pilke(BITMAP * bufor, int x_pilka, int y_pilka)
{
	circle(bufor, x_pilka, y_pilka, rozmiar_pilka, makecol(255,64,64));
	circlefill(bufor, x_pilka, y_pilka, rozmiar_pilka-5, makecol(255,112,41));
	floodfill(bufor, x_pilka, y_pilka+rozmiar_pilka-1, makecol(255,230,102));
}
Exemplo n.º 27
0
void main()
{
	int a[100][100]={0},c,r,i,j=83,k=98,no,tot,ch,ro,co,gd=DETECT,gm,mx,my,x=60,y=75;
	char str[40];
	initgraph(&gd,&gm,"d:\\tc\\bgi");
	clrscr();
	printf("Enter size of  matrix");
	scanf("%d",&c);
	if(c%2==0)
	{
		printf("This is not defined for even numbers.");
		getch();
		exit();
	}
	printf("Enter initial value:");
	scanf("%d",&no);
	clrscr();
	setcolor(WHITE);
	fflush(stdin);
	settextstyle(3,HORIZ_DIR,10);
	setcolor(RED);
	itoa(c,str,10);
	settextstyle(0,HORIZ_DIR,1);
	j=(((c*42))/c)+43;
	mx=getmaxx();
	my=getmaxy();
	rectangle(0,0,mx,my);
	setcolor(RED);
	setfillstyle(SOLID_FILL,BLACK);
	floodfill(mx/2,my/2,BLACK);
	outtextxy(mx/2-150,40,"Magicsquare  of");
	outtextxy(mx/2,40,str);
	printf("\n\n\n");
	rectangle(45,60,(c+1)*42,(c+1)*42);
	setcolor(MAGENTA);
	setbkcolor(BLUE);
	setlinestyle(0,0,1);
	setcolor(MAGENTA);
	for(i=0;i<c-1;i++)
	{
		line(j,60,j,(c+1)*42);
		line(45,k,(c+1)*42,k);
		j+=(((c+1)*42)-45)/c;
		k+=(((c+1)*42)-60)/c;

	}
	c--;
	r=c;
	ro=r;
	co=ro;
	a[0][c/2]=no;
	ro=0;
	co=c/2;
	for(i=no+1;i<=((c+1)*(c+1))+no;i++)
	{
		ro--;
		co++;
		j=ro;
		k=co;
		if(ro<0 && co<=c)
			ro=c;
		if(ro<0 && co>c)
		{
			ro=c;
			co=0;
		}
		if(ro>=0 && co>c)
			co=0;
		if(a[ro][co]!=0)
		{
			ro=ro+2;
			co--;
		}
		if(ro==-1 && co==c+1  || j==-1 && k==c+1)
		{
			ro=1;
			co=c;
		}
	       a[ro][co]=i;
	}
	for(i=0;i<=c;i++)
	{
		x=60;
		for(j=0;j<=c;j++)
		{
		       //	printf("\t%d",a[i][j]);
			itoa(a[i][j],str,10);
			outtextxy(x,y,str);
			x+=40;
		}
		y+=40;
		printf("\n\n");
	}

		getch();
	closegraph();
	restorecrtmode();

}
Exemplo n.º 28
0
void Welcome()
{
	Mouse m;


	setbkcolor(WHITE);
	setviewport(40, 40, 600, 440, 1);

	setfillstyle(SOLID_FILL, LIGHTCYAN);
	setcolor(YELLOW);
	rectangle(0, 0, 560, 400);
	floodfill(50, 50, 14);

    setviewport(40, 40, 580, 420, 1);
	rectangle(20, 20, 540, 380);
	setfillstyle(SOLID_FILL, LIGHTMAGENTA);
	floodfill(21, 300, YELLOW);


	setcolor(BLACK);
	settextstyle(TRIPLEX_FONT, HORIZ_DIR, 8);
	outtextxy(110, 55, "Welcome");
	DisChinese("今天你是设计师",170,165,2,2,10,10);


	setcolor(BLUE);
	setfillstyle(SOLID_FILL, YELLOW);
	ellipse(450,335,0,360,60,20);
	floodfill(450, 335, BLUE);
	DisChinese("开始",430,328,1,1,20,DARKGRAY);


	setcolor(WHITE);
	setfillstyle(SOLID_FILL, WHITE);

	arc(260,818,85,130,470);
	arc(270,820,85,130,470);
	arc(285,822,85,130,470);

	line(61,227,74,400);
	line(61,227,164,211);
	line(164,211,174,360);

	line(184,277,254,265);
	line(184,277,190,355);
	line(254,265,260,355);

	bar(85,245,108,270);
	bar(131,245,155,270);
	bar(85,300,108,330);
	bar(131,300,155,330);

	bar(199,287,215,302);
	bar(230,282,246,298);
	bar(199,320,215,335);
	bar(230,320,246,335);


	while (1)
	{
	    ShowMouse();
	    m=ReadMouse();
        if (m.b == 1)
        {
			if (MouseIn(430,305,500,395))
			{
			    HideMouse();
			    cleardevice();
			    closegraph();
				break;
			}
		}
	}
}
Exemplo n.º 29
0
int main(int argc, char* argv[]) {
	//error messagea
	if  (argc != 5 and argc != 6 and argc != 7) {
		std::cerr << "arguments can not be fit in" << argv[0] ;
		return 1;
	}
	std::string row;
	std::ifstream myFile(argv[1]);

	if (!myFile.good()) {
		std::cerr << "The file is not correct!" << argv[1] << "\n";
	}
	//std::string row; //input each row to a string
	std::vector<std::string> inputs; //Input vectors to hold all the points
	while (std::getline(myFile, row)) {
		inputs.push_back(row);
	}
	std::cout << "The input:"<<std::endl; //print out the input
	for (unsigned int i = 0 ; i < inputs.size() ; ++i ) {
		std::cout << inputs[i] << std::endl;
	}
///////////starts to do the replace, dialation, erosion and floodfill
	std::vector<std::string> results; // create a vector called results for later print out 
	// dilation
	if (argc == 5) {
		results = dilation(inputs, argv[4][0]);
		for (unsigned int i = 0 ; i < results.size() ; ++i ) {
			std::cout << results[i] << std::endl;
		}
	}
	//replace+erosion
	if (argc == 6) {
		std::string a = "replace";
		std::string b = "erosion";
		if (!a.compare(argv[3])) {
			results = replace(inputs, argv[4][0], argv[5][0]);
		}
		if (!b.compare(argv[3])) {
			results = erosion(inputs, argv[4][0], argv[5][0]);
		}
	}
	//floodfill
	if (argc ==7) {
		//convert the string in arguments to integers
		int r = atoi(argv[4]);
		int c = atoi(argv[5]);
		char temp = argv[6][0];
		floodfill(inputs, r, c, temp);
		results = inputs;
	}
	std::cout << "The output:"<<std::endl;
	//print out the output
	for (unsigned int i = 0 ; i < results.size() ; ++i ) {
		std::cout << results[i] << std::endl;
	}
	//output to a file
	std::ofstream outputs;
	outputs.open(argv[2]);
	for (unsigned int i = 0 ; i < results.size() ; ++i) {
		outputs << results[i] <<"\n" ;
	}
	outputs.close();
	return 0;
}
Exemplo n.º 30
0
void shakil::show()
{
 hidemouseptr();
 setcolor(123);

 for(i=0;i<n;i++)
 for(j=0;j<n;j++)
 {
   if(vm[i][j]==10)
   {setcolor(123);
   rectangle(xp1[i][j],yp1[i][j],xp2[i][j],yp2[i][j]);
   setfillstyle(SOLID_FILL,123);
   floodfill(xp1[i][j]+2,yp1[i][j]+2,123);
     }
    if(vm[i][j]==5)
    {setcolor(7);
     rectangle(xp1[i][j],yp1[i][j],xp2[i][j],yp2[i][j]);
      setfillstyle(SOLID_FILL,7);
     floodfill(xp1[i][j]+2,yp1[i][j]+2,7);

    }
   if(vm[i][j]==0)
   { setcolor(BLACK);
     rectangle(xp1[i][j],yp1[i][j],xp2[i][j]+(c12/2),yp2[i][j]+(c12/2));
     setfillstyle(SOLID_FILL,BLACK);
     floodfill(xp1[i][j]+2,yp1[i][j]+2,BLACK);
     line(xp1[i][j],yp2[i][j],xp1[i][j]+(c12/2),yp2[i][j]+(c12/2));
    line(xp2[i][j],yp1[i][j],xp2[i][j]+(c12/2),yp1[i][j]+(c12/2));
   }
   if(vm[i][j]==5||vm[i][j]==10)
   {
    setcolor(RED);
    p=res1[i][j]/100;
    if(p>0)
    {switch(p)
    {case 0:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"0");
	  break;
      case 1:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"1");
	  break;

    case 2:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"2");
	  break;
    case 3:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"3");
	  break;
   case 4:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"4");
	  break;
    case 5:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"5");
	  break;
    case 6:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"6");
	  break;
    case 7:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"7");
	  break;
    case 8:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"8");
	  break;
    case 9:
	  outtextxy(xp1[i][j]+1,(yp1[i][j]+yp2[i][j])/2-10,"9");
	  break;
    }

    }
    m=res1[i][j]/10;
    if(m>9)
    m=m-p*10;
    if(m>0||p>0)
    {switch(m)
    {case 0:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"0");
	  break;
    case 1:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"1");
	  break;

    case 2:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"2");
	  break;
    case 3:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"3");
	  break;
    case 4:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"4");
	  break;
    case 5:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"5");
	  break;
    case 6:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"6");
	  break;
    case 7:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"7");
	  break;
    case 8:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"8");
	  break;
    case 9:
	  outtextxy(xp1[i][j]+10,(yp1[i][j]+yp2[i][j])/2-10,"9");
	  break;



    }

    }
    m=res1[i][j]%10;
    switch(m)
    {case 0:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"0");
	  break;
      case 1:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"1");
	  break;

    case 2:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"2");
	  break;
    case 3:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"3");
	  break;
    case 4:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"4");
	  break;
    case 5:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"5");
	  break;
    case 6:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"6");
	  break;
    case 7:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"7");
	  break;
    case 8:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"8");
	  break;
    case 9:
	  outtextxy(xp1[i][j]+20,(yp1[i][j]+yp2[i][j])/2-10,"9");
	  break;



    }
    setcolor(8);
    line(xp1[i][j]+(c12/2),yp2[i][j]+(c12/2),xp2[i][j]+(c12/2),yp2[i][j]+(c12/2));
    line(xp2[i][j]+(c12/2),yp1[i][j]+(c12/2),xp2[i][j]+(c12/2),yp2[i][j]+(c12/2));
    line(xp1[i][j],yp2[i][j],xp1[i][j]+(c12/2),yp2[i][j]+(c12/2));
    line(xp2[i][j],yp1[i][j],xp2[i][j]+(c12/2),yp1[i][j]+(c12/2));
    // setfillstyle(SOLID_FILL,8);
   //  floodfill(xp2[i][j],yp2[i][j]+2,8);
    }
	}
    setcolor(123);
    rectangle(xp1[0][0]-c12,yp1[0][0]-c12,xp2[n-1][n-1]+c12,yp2[n-1][n-1]+c12);
    setcolor(2);
    rectangle(470,370,520,390);
    setfillstyle(SOLID_FILL,2);
    floodfill(477,376,2);
    setcolor(RED);
    outtextxy(476,369,"EXIT");
    setcolor(2);
    rectangle(470,270,520,290);
    setfillstyle(SOLID_FILL,2);
    floodfill(477,276,2);
    setcolor(RED);
    outtextxy(473,270,"SAVE");
    showmouseptr();

}