⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zhuang.c

📁 一个小游戏
💻 C
字号:
# include <stdlib.h>
# include<graphics.h>
# include <math.h>
# define PI 3.1415926
int a[5],b[5];
drawstar(){
        int k,i;
		setcolor(14);
	for(k=0;k<2;k++){
		line(a[k],b[k],a[k+2],b[k+2]);
		line(a[k],b[k],a[k+3],b[k+3]);	
	}
	line(a[2],b[2],a[4],b[4]);
        setfillstyle(SOLID_FILL,14);
        for(i=0;i<5;i++){
            floodfill(300+25*cos(2*i*PI/5),350-25*sin(2*i*PI/5),14);
        }
        floodfill(300,350,14);
}
disappear(){
      int n;
	for(n=0;n<10;n++){
	    setcolor(0);
            circle(300,350,36);
            setfillstyle(SOLID_FILL,0);
        floodfill(300,350,0);
	}
}
  main()
     { 
          int i,k,n,gdriver, gmode, size,x,y,d; 
		  char key;
		  long m;
          void *buf; 
          gdriver=DETECT; 
          initgraph(&gdriver, &gmode, ""); 
          setbkcolor(0); 
          cleardevice(); 
          setcolor(12); 
          setlinestyle(0,0,1); 
          setfillstyle(1,10); 
          circle(100, 200, 30); 
          floodfill(100, 200, 12); 
          setcolor(RED); 
          circle(85, 190, 6); 
          circle(115, 190, 6); 
          setfillstyle(1,15); 
          floodfill(85,190,4);
          floodfill(115,190,4); 
          putpixel(85,190,0); 
          putpixel(115,190,0);
          setcolor(0);
          line(100,200,92,209); 
          line(100,200,108,209); 
          line(92,209,108,209); 
          arc(100,200,240,300,22);
          size=imagesize(69, 169, 131, 231); 
          buf=malloc(size); 
          getimage(69, 169, 131, 231,buf); 
               putimage(70, 170, buf, COPY_PUT); 
               putimage(500, 170, buf, COPY_PUT); 
			   for(d=0;d<5;d++){
	              a[d]=300+35*cos(2*d*PI/5);
	              b[d]=350-35*sin(2*d*PI/5);
			  }
          setcolor(5);
          outtextxy(150,300,"Press any key,we will begin to hit!");
          getch();
          setcolor(0);
          outtextxy(150,300,"Press any key,we will begin to hit!");
          loop: setcolor(5);
          outtextxy(205,300,"We will hit 5 times!");
		  for(k=0;k<5;k++){
          for(i=0; i<185; i++){
               putimage(70+i, 170, buf, COPY_PUT);
               putimage(500-i, 170, buf, COPY_PUT);
          }
		  drawstar();
		  for(n=1;n<360;n+=5){
			  x=ceil(310+30*cos(n*PI/180));
		      y=ceil(120-30*sin(n*PI/180));
		      setcolor(1+k);
			  setlinestyle(0,0,3);
			  line(310,120,x,y);
			  for(m=0;m<999900;m++){}
			  setcolor(0);
			  line(310,120,x,y);
		  }
		  disappear();
          for(i=0;i<185; i++){
               putimage(255-i, 170, buf, COPY_PUT);
               putimage(315+i, 170, buf, COPY_PUT);
          }
		  }
          setcolor(0);
          outtextxy(205,300,"We will hit 5 times!");
	      op:setcolor(13);
          outtextxy(160,300,"ESC:leave.. ENTER:make round.. else:again!");
		  key=bioskey(0);
		  if(key!=0x1b&&key!=0xd) {
			  setcolor(0);
			  outtextxy(160,300,"ESC:leave.. ENTER:make round.. else:again!");
			  goto loop;
		  }
		  else if(key==0xd){
			  cleardevice();
			  setcolor(0);
           outtextxy(160,300,"ESC:leave.. ENTER:make round.. else:again!");
		   setcolor(5);
	       outtextxy(205,300,"We will round 3 times!");
        	for(d=0;d<3;d++){
				for(i=0; i<360; i+=5){
					 for(m=0;m<9999999;m++){}
              putimage(70+40*cos(i*PI/180), 170-40*sin(i*PI/180), buf, COPY_PUT);
              putimage(500+40*cos(i*PI/180), 170-40*sin(i*PI/180), buf, COPY_PUT);
				}
			}
			cleardevice();
			 putimage(70, 170, buf, COPY_PUT);
             putimage(500, 170, buf, COPY_PUT);
			setcolor(0);
	        outtextxy(205,300,"We will round 2 times!");
			goto op;
		  }
		 closegraph();
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -