Tuesday 10 November 2015

How to move a car in C++ (Computer Graphics)- (Source code)

/*Moving a car*/

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

void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\bgi");


for (int i=0;i<500;i++)
{
/***CAR BODY ******/
line(50+i,370,90+i,370);
arc(110+i,370,0,180,20);
line(130+i,370,220+i,370);
arc(240+i,370,0,180,20);
line(260+i,370,300+i,370);
line(300+i,370,300+i,350);
line(300+i,350,240+i,330);
line(240+i,330,200+i,300);
line(200+i,300,110+i,300);
line(110+i,300,80+i,330);
line(80+i,330,50+i,340);
line(50+i,340,50+i,370);

/***CAR Windows***/
line(165+i,305,165+i,330);
line(165+i,330,230+i,330);
line(230+i,330,195+i,305);
line(195+i,305,165+i,305);

line(160+i,305,160+i,330);
line(160+i,330,95+i,330);
line(95+i,330,120+i,305);
line(120+i,305,160+i,305);

/**Wheels**/
circle(110+i,370,17);
circle(240+i,370,17);

delay(10);
cleardevice();

line(0,390,639,390);  //ROAD
}
getch();
}


69 comments:

  1. Replies
    1. Sir kya mai isse mini project me de skti hu I m the student of bca 3rd sem

      Delete
  2. How did you know the numbers(coordinates?) for the lines and arcs of the car

    ReplyDelete
    Replies
    1. He might have used and coordinate find in application such as AutoCAD

      Delete
    2. yes plz tell me how you do this
      make a video on this

      Delete
  3. Yeah answer me please how do you. Notify the coordinates in that program please give me a reference for that i want to know thank you...😁

    ReplyDelete
  4. Yeah answer me please how do you. Notify the coordinates in that program please give me a reference for that i want to know thank you...😁

    ReplyDelete
  5. its showing me some graphic error plzz help out

    ReplyDelete
    Replies
    1. ///ANIMATION CAR(Graphics)
      #include
      #include
      int main()
      {
      int gd=DETECT,gm;
      initgraph(&gd,&gm,"C:\\TC\\BGI");

      for (int i=0;i<500;i++)
      {
      /** CAR BODY **/
      line(50+i,370,90+i,370);
      arc(110+i,370,0,180,20);
      line(130+i,370,220+i,370);
      arc(240+i,370,0,180,20);
      line(260+i,370,300+i,370);
      line(300+i,370,300+i,350);
      line(300+i,350,240+i,330);
      line(240+i,330,200+i,300);
      line(200+i,300,110+i,300);
      line(110+i,300,80+i,330);
      line(80+i,330,50+i,340);
      line(50+i,340,50+i,370);

      /** CAR Windows **/
      line(165+i,305,165+i,330);
      line(165+i,330,230+i,330);
      line(230+i,330,195+i,305);
      line(195+i,305,165+i,305);
      line(160+i,305,160+i,330);
      line(160+i,330,95+i,330);
      line(95+i,330,120+i,305);
      line(120+i,305,160+i,305);

      /** Wheels **/
      circle(110+i,370,17);
      circle(240+i,370,17);

      delay(30);
      cleardevice();

      line(0,390,639,390); ///ROAD
      }
      getch();
      }

      ///Credit goes to #TPA_ARMY & modified by me
      /// ** THE END **///

      Delete
    2. can you give me this code please "ABC" Green fields – Students’ movements & some of them are enjoying sunshine.

      Delete
  6. My *.exe has stopped working, how to fix it? Please help me, thanks!

    ReplyDelete
    Replies
    1. ///ANIMATION CAR(Graphics)
      #include
      #include
      int main()
      {
      int gd=DETECT,gm;
      initgraph(&gd,&gm,"C:\\TC\\BGI");

      for (int i=0;i<500;i++)
      {
      /** CAR BODY **/
      line(50+i,370,90+i,370);
      arc(110+i,370,0,180,20);
      line(130+i,370,220+i,370);
      arc(240+i,370,0,180,20);
      line(260+i,370,300+i,370);
      line(300+i,370,300+i,350);
      line(300+i,350,240+i,330);
      line(240+i,330,200+i,300);
      line(200+i,300,110+i,300);
      line(110+i,300,80+i,330);
      line(80+i,330,50+i,340);
      line(50+i,340,50+i,370);

      /** CAR Windows **/
      line(165+i,305,165+i,330);
      line(165+i,330,230+i,330);
      line(230+i,330,195+i,305);
      line(195+i,305,165+i,305);
      line(160+i,305,160+i,330);
      line(160+i,330,95+i,330);
      line(95+i,330,120+i,305);
      line(120+i,305,160+i,305);

      /** Wheels **/
      circle(110+i,370,17);
      circle(240+i,370,17);

      delay(30);
      cleardevice();

      line(0,390,639,390); ///ROAD
      }
      getch();
      }

      ///Credit goes to #TPA_ARMY & modified by me
      /// ** THE END **///

      Delete
    2. Function'delay'should have prototype this type of error is showing hear so how to solve it please and me fast

      Delete
  7. Sir kya ya hum minor project m de skta h sir mai BE cs ki student hu

    ReplyDelete
    Replies
    1. Have you got output,the programming is running but the output is not displaying?In addition, error is not occurring too..

      Delete
  8. sir , it shows graphics error

    ReplyDelete
    Replies
    1. ///ANIMATION CAR(Graphics)
      #include
      #include
      int main()
      {
      int gd=DETECT,gm;
      initgraph(&gd,&gm,"C:\\TC\\BGI");

      for (int i=0;i<500;i++)
      {
      /** CAR BODY **/
      line(50+i,370,90+i,370);
      arc(110+i,370,0,180,20);
      line(130+i,370,220+i,370);
      arc(240+i,370,0,180,20);
      line(260+i,370,300+i,370);
      line(300+i,370,300+i,350);
      line(300+i,350,240+i,330);
      line(240+i,330,200+i,300);
      line(200+i,300,110+i,300);
      line(110+i,300,80+i,330);
      line(80+i,330,50+i,340);
      line(50+i,340,50+i,370);

      /** CAR Windows **/
      line(165+i,305,165+i,330);
      line(165+i,330,230+i,330);
      line(230+i,330,195+i,305);
      line(195+i,305,165+i,305);
      line(160+i,305,160+i,330);
      line(160+i,330,95+i,330);
      line(95+i,330,120+i,305);
      line(120+i,305,160+i,305);

      /** Wheels **/
      circle(110+i,370,17);
      circle(240+i,370,17);

      delay(30);
      cleardevice();

      line(0,390,639,390); ///ROAD
      }
      getch();
      }

      ///Credit goes to #TPA_ARMY & modified by me
      /// ** THE END **///

      Delete
  9. how do i paste the code in?

    ReplyDelete
  10. during compile it shows 0 errors but during run it shows linker error, what should i do now, please help me

    ReplyDelete
  11. during compile it shows 0 errors but during run it shows linker error, what should i do now, please help me

    ReplyDelete
    Replies
    1. ///ANIMATION CAR(Graphics)
      #include
      #include
      int main()
      {
      int gd=DETECT,gm;
      initgraph(&gd,&gm,"C:\\TC\\BGI");

      for (int i=0;i<500;i++)
      {
      /** CAR BODY **/
      line(50+i,370,90+i,370);
      arc(110+i,370,0,180,20);
      line(130+i,370,220+i,370);
      arc(240+i,370,0,180,20);
      line(260+i,370,300+i,370);
      line(300+i,370,300+i,350);
      line(300+i,350,240+i,330);
      line(240+i,330,200+i,300);
      line(200+i,300,110+i,300);
      line(110+i,300,80+i,330);
      line(80+i,330,50+i,340);
      line(50+i,340,50+i,370);

      /** CAR Windows **/
      line(165+i,305,165+i,330);
      line(165+i,330,230+i,330);
      line(230+i,330,195+i,305);
      line(195+i,305,165+i,305);
      line(160+i,305,160+i,330);
      line(160+i,330,95+i,330);
      line(95+i,330,120+i,305);
      line(120+i,305,160+i,305);

      /** Wheels **/
      circle(110+i,370,17);
      circle(240+i,370,17);

      delay(30);
      cleardevice();

      line(0,390,639,390); ///ROAD
      }
      getch();
      }

      ///Credit goes to #TPA_ARMY & modified by me
      /// ** THE END **///

      Delete
  12. getch is not working output comes and goes in split seconds :-(

    ReplyDelete
  13. Yess the getch is not working wjt to do

    ReplyDelete
  14. Sir, it's showing 0 error then also ,,,,
    The output is not coming����

    ReplyDelete
  15. Hi there is 1 error about iostream.h......How I'll correct it to run the program.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. ///ANIMATION CAR(Graphics)
      #include
      #include
      int main()
      {
      int gd=DETECT,gm;
      initgraph(&gd,&gm,"C:\\TC\\BGI");

      for (int i=0;i<500;i++)
      {
      /** CAR BODY **/
      line(50+i,370,90+i,370);
      arc(110+i,370,0,180,20);
      line(130+i,370,220+i,370);
      arc(240+i,370,0,180,20);
      line(260+i,370,300+i,370);
      line(300+i,370,300+i,350);
      line(300+i,350,240+i,330);
      line(240+i,330,200+i,300);
      line(200+i,300,110+i,300);
      line(110+i,300,80+i,330);
      line(80+i,330,50+i,340);
      line(50+i,340,50+i,370);

      /** CAR Windows **/
      line(165+i,305,165+i,330);
      line(165+i,330,230+i,330);
      line(230+i,330,195+i,305);
      line(195+i,305,165+i,305);
      line(160+i,305,160+i,330);
      line(160+i,330,95+i,330);
      line(95+i,330,120+i,305);
      line(120+i,305,160+i,305);

      /** Wheels **/
      circle(110+i,370,17);
      circle(240+i,370,17);

      delay(30);
      cleardevice();

      line(0,390,639,390); ///ROAD
      }
      getch();
      }

      ///Credit goes to #TPA_ARMY & modified by me
      /// ** THE END **///

      Delete
    3. This comment has been removed by the author.

      Delete
    4. Dear, Joshi. If you use only these(include & include) header files then you can access this animation(moving) of car. Thanks TPA ARMY.

      Delete
  16. This comment has been removed by the author.

    ReplyDelete
  17. http://winbgim.codecutter.org/ link for graphics, btw thank you author for sharing your knowledge

    ReplyDelete
  18. Why it cant work in dev c++ compiler?

    ReplyDelete
  19. Bro what is that line 50+i ,370 90 370 and
    Arc 110,370 what is that bro

    ReplyDelete
  20. Showing error as undefined symbol

    ReplyDelete
  21. ShowS error as pixel out of range

    ReplyDelete
  22. please give me a source code in vb.net

    ReplyDelete
  23. Why this program is not working in my pc.....in output it is mentioned that. ....BGI Error :Graphics not initialized (use 'initgraph').....

    ReplyDelete
  24. What is a work of this line?
    (&gd,&gm,"c:\\tc\\bgi");

    ReplyDelete
  25. this code is error
    include ar pora kisu nai

    ReplyDelete
  26. The worst part of it was that the software only worked intermittently and the data was not accurate. You obviously canot confront anyone about what you have discovered if the information is not right Elia And Ponto

    ReplyDelete
  27. My friends Please help me create a computer graphics project using a C ++ language that has two or more interfaces

    ReplyDelete
  28. Getch is not working output comes and goes in split seconds. Please help

    ReplyDelete
  29. I'm getting 0 errors but output not showing what's the problem sir....

    ReplyDelete
  30. This does not run in my compiler

    ReplyDelete
  31. Cau u give the code of a child which is using slide in the play ground

    ReplyDelete
  32. Please if i have a code and it doesnt want to work can you see it and fix it

    ReplyDelete
  33. hi,

    Thank you for sharing information. This blog is Very Useful For me.

    Branding And Logo Design

    ReplyDelete
  34. Nice to read your article! I am looking forward to sharing your adventures and experiences. moving company west hollywood

    ReplyDelete
  35. I love the way you write and share your niche! Very interesting and different! Keep it coming!
    Webdesign

    ReplyDelete
  36. I got what you mean , thanks for posting .Woh I am happy to find this website through google. Party Bus Toronto

    ReplyDelete
  37. I read your blog frequently and I just thought I’d say keep up the amazing work! Online Quran Academy

    ReplyDelete
  38. what source code now is easy to run ?? except the snake and dinosaur? please help me 🙇

    ReplyDelete
  39. Amazing knowledge and I like to share this kind of information with my friends and hope they like it they why I do Rancho Cucamonga To Lax Transportation

    ReplyDelete