Moving Car in C programming language



Moving Car in C programming language
published by

5921


#include <stdio.h>

#include <conio.h>

#include <graphics.h>

int main()

{

    int gd=DETECT,gm,i;

    initgraph(&gd,&gm,"C:\\t\\bgi");

 

    setcolor(YELLOW);

    setbkcolor(BLACK);

    home:

    for(i=0;i<500;i++)

    {

 

 

    line(200+i,100,400+i,100);

 

    line(200+i,100,120+i,180);// left side angle

    line(120+i,180,50+i,180);//left line body

    line(50+i,180,50+i,250);

    line(150+i,250,50+i,250);

 

    line(400+i,100,500+i,180);// right side angle

    line(500+i,180,570+i,180);//right line body

    line(570+i,180,570+i,250);

    line(570+i,250,470+i,250);

 

    circle(180+i,250,30);// left wheel

    circle(180+i,250,8);

    circle(440+i,250,30);// right wheel

    circle(440+i,250,8);

 

    line(210+i,250,410+i,250);

    line(200+i,110,130+i,180);// left door angle

    line(200+i,110,280+i,110);

    line(130+i,180,130+i,205);

    line(130+i,205,280+i,205);

    line(280+i,205,280+i,110);

 

    line(390+i,110,480+i,180);// left door angle

    line(390+i,110,300+i,110);

    line(480+i,180,480+i,205);

    line(480+i,205,300+i,205);

    line(300+i,205,300+i,110);

_sleep(100);

cleardevice();

line(0,280,700,280);

if(i==499) goto home;

    }

    getch();

}