Write a Program to make a moving colored car using inbuilt functions.

 

Write a Program to make a moving colored car using inbuilt functions.


  1. #include<graphics.h>  
  2. #include<conio.h>  
  3. int main()  
  4. {  
  5.     intgd=DETECT,gm, i, maxx, cy;  
  6.     initgraph(&gd, &gm, "C:\\TC\\BGI");  
  7.     setbkcolor(WHITE);  
  8.     setcolor(RED);  
  9.     maxx = getmaxx();  
  10.     cy = getmaxy()/2;  
  11.     for(i=0;i<maxx-140;i++)  
  12.         {  
  13.         cleardevice();  
  14.         line(0+i,cy-20, 0+i, cy+15);  
  15.         line(0+i, cy-20, 25+i, cy-20);  
  16.         line(25+i, cy-20, 40+i, cy-70);  
  17.         line(40+i, cy-70, 100+i, cy-70);  
  18.         line(100+i, cy-70, 115+i, cy-20);  
  19.         line(115+i, cy-20, 140+i, cy-20);  
  20.         line(0+i, cy+15, 18+i, cy+15);  
  21.         circle(28+i, cy+15, 10);  
  22.         line(38+i, cy+15, 102+i, cy+15);  
  23.         circle(112+i, cy+15,10);  
  24.         line(122+i, cy+15 ,140+i,cy+15);  
  25.         line(140+i, cy+15, 140+i, cy-20);  
  26.         rectangle(50+i, cy-62, 90+i, cy-30);  
  27.         setfillstyle(1,BLUE);  
  28.         floodfill(5+i, cy-15, RED);  
  29.         setfillstyle(1, LIGHTBLUE);  
  30.         floodfill(52+i, cy-60, RED);  
  31.         delay(10);  
  32.          }  
  33.     getch();  
  34.     closegraph();  
  35.     return 0;  
  36. }  

Output:

Computer Graphics Programs
Computer Graphics Programs

Post a Comment

Previous Post Next Post