#include #include #include #include #include #include #include #include #include #define BD_WID 100 #define BD_HEI 50 #define WL_RAD 10 #define LV_LEN 100 void cart(int x, int y, int deg, int flg); void main(void) { int gdrv = VGA, gmode = VGAHI; int i, x, posx, posy, deg; initgraph(&gdrv, &gmode, "d:\\borlandc\\bgi"); posx = 100; posy = 200; deg = -10; cart(posx, posy, deg, 1); for (i = 0; i < 30; i++) { x = posx + i * 10; cart(x , posy, deg, 1); delay(3000); cart(x , posy, deg, 0); deg += 3; } cart(x , posy, deg, 1); getch(); closegraph(); } void cart(int x, int y, int deg, int flg) { int x1, x2, y1, y2; int cx, col; double rad; x1 = x; y1 = y; x2 = x1 + BD_WID; y2 = y1 + BD_HEI; col = (flg)? LIGHTGRAY: BLACK; setcolor(col); rectangle(x1, y1, x2, y2); cx = x1 + WL_RAD * 1.8; col = (flg)? YELLOW: BLACK; setcolor(col); circle(cx, y2, WL_RAD); cx = x2 - WL_RAD * 1.8; circle(cx, y2, WL_RAD); cx = (x1 + x2 ) / 2; col = (flg)? LIGHTGRAY: BLACK; setcolor(col); arc(cx, y1, 0, 180, WL_RAD); x1 = x + BD_WID / 2; y1 = y; rad = deg * M_PI / 180.; x2 = x1 + LV_LEN * sin(rad); y2 = y1 - LV_LEN * cos(rad); col = (flg)? LIGHTRED: BLACK; setcolor(col); line(x1, y1, x2, y2); }