用C语言的图像函数画一个简单的坦克图样
#include "graphics.h"
#include "conio.h"
void Tanke(int x,int y,int R,int TColor,int FColor)
{
int i,j,d,t;
d=R/4;
t=d*0.6;
setcolor(TColor);
/* ------------------------------------------------------------------------------ */
line(x-R,y,x+R-t,y);
line(x-R,y,x-R+d,y+2*d);
line(x-R+d,y+2*d,x+3*d,y+2*d);
line(x+3*d,y+2*d,x+R-t,y);
/* ------------------------------------------------------------------------------ */
line(x-R,y,x-R+t,y-t);
line(x-R+t,y-t,x-2*d,y-t);
line(x-2*d,y-t,x-2*d+t,y-d-t);
line(x-2*d+t,y-d-t,x-3*d,y-d-t);
line(x-3*d,y-d-t,x-3*d+t,y-2*d);
line(x-3*d+t,y-2*d,x+R-t,y-2*d);
line(x+R-t,y-2*d,x+R-t,y);
/* ------------------------------------------------------------------------------ */
line(x-3*d,y-d-t,x-2*d,y-t);
/* ------------------------------------------------------------------------------ */
line(x-R+d-t,y+2*(d-t),x+3*d+R*0.04,y+2*(d-t));
for(i=0;i<2*(R/d-1);i++)
line(x-3*d+i*d,y+2*(d-t),x-3*d+i*d,y+2*d);
/* ------------------------------------------------------------------------------ */
setfillstyle(1,TColor);
bar(x-d*1.2,y-d*0.6,x+d*2,y-d*0.2);
line(x-d*1.2,y-d*0.6,x-d*0.6,y-d*1.8);
line(x-d*0.6,y-d*1.8,x+d*2.4,y-d*1.8);
line(x+d*2.4,y-d*1.8,x+d*2,y-d*0.6);
line(x-d*2.4,y-d*1.8,x+d*2.4,y-d*1.4);
line(x+d*2,y-d*0.2,x+d*2.4,y-d*1.4);
/* ------------------------------------------------------------------------------ */
sector(x+d*0.6,y-d,0,180,d*1.2,d*1.4);
/* ------------------------------------------------------------------------------ */
for(i=0;i<d*0.3;i++) //画炮杆
line(x+d*0.2,y-d*1.8+i,x-d*2.5,y-d*1.8+i);
setfillstyle(1,FColor);
bar(x-d*3,y-d*1.9,x-d*2.3,y-d*1.3); //画炮头
}
main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"D:\Program Files\CYuYan\WinTc");
setbkcolor(0);
Tanke(300,200,50,WHITE,RED);
getch();
closegraph();
return 0;
}
说明:"D:\Program Files\CYuYan\WinTc"表面我所用的编译软件所在的位置,WinTc为启动程序名称。对着多面编译软件的图标点击右键选择“属性”,直接复制和粘贴就可以了,不过WinTc后面的.exe要去掉