Friday 23 December 2011

Man walking on a road -C++ program

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
void man();
int main()
{
   
    initwindow(1050,1050 , "First Sample");
    man();
   
    getch();
}
void man()
{
     float t=3.14/180,j=0.0;
     int i,p,k=0,l,x1,y1,x2,y2,xf,yf,x,y,m=0; xf=201;yf=399;
     while(1)
     {
     for(i=0,j=0;(i<70||j<45);i++,j=j+1,k++)
     {
     cleardevice();
     line(0,400,1050,400);
     line(0,600,1050,600);
     line(200+k,400,200+k,200);
     circle(200+k,170,30);
     circle(225+k,160,3);
     x=199;y=249;
     x2=x+(280-x)*sin(t*j)-(300-y)*cos(t*j);
     y2=y+(280-x)*cos(t*j)+(300-y)*sin(t*j);
     line(200+k,250,x2+k,y2);
     x1=x+(280-x)*cos(t*j)-(300-y)*sin(t*j);
     y1=y+(280-x)*sin(t*j)+(300-y)*cos(t*j);
     line(200+k,250,x1+k,y1);
     x2=xf+(280-xf)*sin(t*i)-(500-yf)*cos(t*i);
     y2=yf+(280-xf)*cos(t*i)+(500-yf)*sin(t*i);
     line(200+k,400,x2+k,y2);
     x1=xf+(280-xf)*cos(t*i)-(500-yf)*sin(t*i);
     y1=yf+(280-xf)*sin(t*i)+(500-yf)*cos(t*i);
     line(200+k,400,x1+k,y1);
     delay(3);
     }
     }
     }

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More