Simple program to create a moving car in graphics

Simple program to create a moving car in graphics

#include<graphics.h>
#include<conio.h>
#include<dos.h>

void main()
{
int gdriver=DETECT,gmode,i=0,j=0;
initgraph(&gdriver,&gmode,”c:\turboc3\bgi”);

for(i;i<420;++i)
{
line(0,245,650,245);
line(0+i,200,210+i,200);
line(50+i,200,70+i,170);
line(70+i,170,140+i,170);
line(140+i,170,160+i,200);
line(85+i,170,85+i,200);
line(125+i,170,125+i,200);

line(0+i,200,0+i,230);
line(210+i,200,210+i,230);
line(0+i,230,50+i,230);
circle(65+i,230,15);
line(80+i,230,130+i,230);
circle(145+i,230,15);
line(210+i,230,160+i,230);

pieslice(65+i,230,359-j,360-j,15);
pieslice(65+i,230,179-j,180-j,15);
pieslice(65+i,230,89-j,90-j,15);
pieslice(65+i,230,269-j,270-j,15);

pieslice(145+i,230,359-j,360-j,15);
pieslice(145+i,230,179-j,180-j,15);
pieslice(145+i,230,89-j,90-j,15);
pieslice(145+i,230,269-j,270-j,15);

if(j==179)
j=0;
++j;
delay(30);
cleardevice();
}
closegraph();
}

Subscribe To Get Latest Tutorials Directly In Your Inbox!
Enter Your Email Address Below:

HAND

21 comments for “Simple program to create a moving car in graphics

  1. Muhamad Syafiee
    April 3, 2013 at 4:08 pm

    when I try to run at borland 5.02, it say “#error BGI graphics not supported under Windows”

    what the function of “c:turboc3bgi”?

    • April 3, 2013 at 8:25 pm

      Hello Mauhamad
      It is the path of the bgi folder which contains the necessary files to run graphics program. This is different for different compilers, just change path “c:\turboc3\bgi” to correct bgi folder path and the error will be removed.
      If you have further queries than let me know.

    • Muhamad Syafiee
      April 4, 2013 at 2:49 am

      owh, i’ll try to change it first.. later i’ll give you a respond. thanks. :)

  2. Subhadeep Dey
    April 12, 2013 at 6:58 pm

    I am using Turbo C++ 4.5 in Windows 7 and whenever I tried to run this program, it said “BGI Graphics not supported under Windows”. What should I do?

  3. Dinesh Tolani
    June 7, 2013 at 2:35 pm

    this will not run on linux
    bcoz of dos.h and conio.h is not in GCC compiler

    • June 9, 2013 at 7:25 pm

      Yes you are right bro, this will not work in linux as GCC does not have dos.h and conio.h. You can try there alternatives by searching on google. I can’t help you in this case because i have very less experience of working on GCC.

  4. muneeb memon
    November 12, 2013 at 7:04 pm

    bro i want some help in C programming can u plzzz help me this is my email muneebmemon5@gmail or can u give me your email i have some questions to ask about C thankx

  5. TC Hsieh
    November 13, 2013 at 2:09 pm

    where sould I put the EGAVGA.BGI lib to in visual studio 2012 , win 7 ?

  6. srinivas devaki
    November 13, 2013 at 2:40 pm

    sir
    i am just a student,
    i want to know that why did you mentioned your email without any fear of spam?

    • November 13, 2013 at 5:37 pm

      there is no need to worry about this as my email is also mentioned on the contact us page of this blog.

  7. ashish arora
    November 13, 2013 at 3:44 pm

    nice yaar it really works

  8. Debashis Sarkar
    November 13, 2013 at 6:53 pm

    1 22 333 how to create this program? plse help me

    • November 15, 2013 at 11:30 am

      for(i=1;i<=3;++i)
      {
      for(j=1;j<=i;++j)
      cout<<i;
      cout<<”n”;
      }

  9. Raigha tshu' bIG bLOG'S
    November 14, 2013 at 12:52 am

    when i get C++ in full version for window 7 ?

  10. Nirvana Rupali
    November 14, 2013 at 7:29 am

    #include
    #include
    #include

    are out of date :)

  11. Sohail Nazar
    November 14, 2013 at 9:41 am

    we have error of graphics.h header file
    1>d:programmingc sharpemovingcarmovingcarsource.cpp(3): fatal error C1083: Cannot open include file: ‘graphics.h’: No such file or directory

  12. Edgar Aguilar Mota
    November 24, 2013 at 3:18 pm

    can help me someone?
    i don’t find c:turboc3bgi
    who know what is that?
    i am a student and want to learn please

    • November 24, 2013 at 5:56 pm

      Hello,
      It is the path of the bgi folder which contains the necessary files to run graphics program.
      If you have further queries than let me know.

  13. Hitesh Modhwadia
    January 24, 2014 at 6:02 pm

    Thankuuuu…..!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *