level 1
c闲人
楼主
以下是一个用线和矩形绘制的简单赛车#include
#include
void main(void){ int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode, ""); setbkcolor(7); setwritemode(XOR_PUT); setcolor(BLUE); setlinestyle(SOLID_LINE,0,3); rectangle(280,350,320,390); rectangle(270,340,330,350); rectangle(290,320,310,340); rectangle(270,390,330,400); setcolor(5); line(290,350,290,390); line(300,300,300,320); line(300,350,300,390); line(310,350,310,390); line(285,300,315,300); getch(); closegraph();}接下来我们试着绘制赛道,周围的绿化树木和简单的集装箱车代码如下:#include
#include
#include
#include
#include
constint u = 26;int i = 2;int j = 3;void road(void){int h;for(h=0;h<4;h++)line(150+h*100,0,150+h*100,472);for(h=0;h<3;h++){setlinestyle(3,0,1);line(200+h*100,0,200+h*100,472);settextstyle(1,HORIZ_DIR,3);}}void tree(void){int w;int poly[14];setcolor(10);setlinestyle(SOLID_LINE,0,3);for (w=-3;w<3;w=w+2){line(85 , -25+u*15+w*157 , 85 , 35+u*15+w*157);line(95 , -25+u*15+w*157 , 95 , 35+u*15+w*157);line(105 , -25+u*15+w*157 , 105 , 35+u*15+w*157);line(115 , -25+u*15+w*157 , 115 , 35+u*15+w*157);line(75 , -9+u*15+w*157 , 75 , 19+u*15+w*157);line(125 , -9+u*15+w*157 , 125 , 19+u*15+w*157);} for (w=-2;w<3;w=w+2) {poly[0] = 530;poly[1] = u*15+w*157;poly[2] =515;poly[3] = 25+u*15+w*157;poly[4] =485;poly[5] =25+u*15+w*157 ;poly[6] =470;poly[7] =u*15+w*157 ;poly[8] =485;poly[9] =-25+u*15+w*157;poly[10] =515;poly[11] =-25+u*15+w*157 ;poly[12] = poly[0];poly[13] = poly[1];drawpoly(7,poly); }}void truck(void){setcolor(2);setlinestyle(SOLID_LINE,0,3);rectangle(170+i*100,j*10,230+i*100,60+j*10);rectangle(160+i*100,70+j*10,240+i*100,260+j*10);line(180+i*100,70+j*10,180+i*100,260+j*10);line(200+i*100,70+j*10,200+i*100,260+j*10);line(220+i*100,70+j*10,220+i*100,260+j*10);}void car(void){setcolor(BLUE);setlinestyle(SOLID_LINE,0,3);rectangle(280,350,320,390);rectangle(270,340,330,350);rectangle(290,320,310,340);rectangle(270,390,330,400);setcolor(5);line(290,350,290,390);line(300,300,300,320);line(300,350,300,390);line(310,350,310,390);line(285,300,315,300);}void main(void){int gdriver = DETECT , gmode,w; initgraph(&gdriver, &gmode, "");setbkcolor(7);setcolor(WHITE);setwritemode(XOR_PUT);road();tree();truck();car();getch();closegraph();}
2004年10月22日 13点10分
1
#include
void main(void){ int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode, ""); setbkcolor(7); setwritemode(XOR_PUT); setcolor(BLUE); setlinestyle(SOLID_LINE,0,3); rectangle(280,350,320,390); rectangle(270,340,330,350); rectangle(290,320,310,340); rectangle(270,390,330,400); setcolor(5); line(290,350,290,390); line(300,300,300,320); line(300,350,300,390); line(310,350,310,390); line(285,300,315,300); getch(); closegraph();}接下来我们试着绘制赛道,周围的绿化树木和简单的集装箱车代码如下:#include
#include
#include
#include
#include
constint u = 26;int i = 2;int j = 3;void road(void){int h;for(h=0;h<4;h++)line(150+h*100,0,150+h*100,472);for(h=0;h<3;h++){setlinestyle(3,0,1);line(200+h*100,0,200+h*100,472);settextstyle(1,HORIZ_DIR,3);}}void tree(void){int w;int poly[14];setcolor(10);setlinestyle(SOLID_LINE,0,3);for (w=-3;w<3;w=w+2){line(85 , -25+u*15+w*157 , 85 , 35+u*15+w*157);line(95 , -25+u*15+w*157 , 95 , 35+u*15+w*157);line(105 , -25+u*15+w*157 , 105 , 35+u*15+w*157);line(115 , -25+u*15+w*157 , 115 , 35+u*15+w*157);line(75 , -9+u*15+w*157 , 75 , 19+u*15+w*157);line(125 , -9+u*15+w*157 , 125 , 19+u*15+w*157);} for (w=-2;w<3;w=w+2) {poly[0] = 530;poly[1] = u*15+w*157;poly[2] =515;poly[3] = 25+u*15+w*157;poly[4] =485;poly[5] =25+u*15+w*157 ;poly[6] =470;poly[7] =u*15+w*157 ;poly[8] =485;poly[9] =-25+u*15+w*157;poly[10] =515;poly[11] =-25+u*15+w*157 ;poly[12] = poly[0];poly[13] = poly[1];drawpoly(7,poly); }}void truck(void){setcolor(2);setlinestyle(SOLID_LINE,0,3);rectangle(170+i*100,j*10,230+i*100,60+j*10);rectangle(160+i*100,70+j*10,240+i*100,260+j*10);line(180+i*100,70+j*10,180+i*100,260+j*10);line(200+i*100,70+j*10,200+i*100,260+j*10);line(220+i*100,70+j*10,220+i*100,260+j*10);}void car(void){setcolor(BLUE);setlinestyle(SOLID_LINE,0,3);rectangle(280,350,320,390);rectangle(270,340,330,350);rectangle(290,320,310,340);rectangle(270,390,330,400);setcolor(5);line(290,350,290,390);line(300,300,300,320);line(300,350,300,390);line(310,350,310,390);line(285,300,315,300);}void main(void){int gdriver = DETECT , gmode,w; initgraph(&gdriver, &gmode, "");setbkcolor(7);setcolor(WHITE);setwritemode(XOR_PUT);road();tree();truck();car();getch();closegraph();}