Thursday, 23 October 2014

Moving Truck

Moving Truck

Hey friends here is one of the easiest way of creating a truck animation.
Code:
#include<dos.h>
#include<graphics.h>
#include<iostream.h>
#include<conio.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
for(int i=0;i<=getmaxx();i+=5)
{
delay(60);
cleardevice();
line(0,385,getmaxx(),385);
int poly[16]={20+i,350,100+i,350,100+i,325,125+i,325,150+i,350,150+i,375,20+i,375,20+i,350};
setfillstyle(1,RED);
fillpoly(8,poly);
setfillstyle(1,WHITE);
fillellipse(40+i,375,10,10);
fillellipse(120+i,+375,10,10);
}

getch();

}

Output:


No comments:

Post a Comment