Friday 23 December 2011

Vehicles moving on road- C graphics program

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
 int main()
{
    int i,j,k,l,m,n,p;
    initwindow(600, 400, "First Sample");

  line(0,160,700,160);
  line(0,275,700,275);
    for(i=0,j=500;i<500;i=i+2,j=j-3)
    {               
                     setcolor(15);
                      rectangle(25+j,225,75+j,245);
                      line(25+j,235,75+j,235);
                      circle(38+j,250,5);
                      circle(68+j,250,5);
                      delay(5);
                      setcolor(0);
                      rectangle(25+j,225,75+j,245);
                      line(25+j,235,75+j,235);
                      circle(38+j,250,5);
                      circle(68+j,250,5);
                      setcolor(15);
                      rectangle(25+i,165,75+i,200);
                      rectangle(75+i,175,85+i,200);
                      circle(38+i,205,5);
                      circle(68+i,205,5);
                      delay(5);
                      setcolor(0);
                      rectangle(25+i,165,75+i,200);
                      rectangle(75+i,175,85+i,200);
                      circle(38+i,205,5);
                      circle(68+i,205,5);
                      }
                      setcolor(15);
                      rectangle(25+i,165,75+i,200);
                      rectangle(75+i,175,85+i,200);
                      circle(38+i,205,5);
                      circle(68+i,205,5);
 getch();
}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More