Thursday, 9 January 2014

Simple Animation Using C

Simple Animation Using C


Source:
view source


01#include<stdio.h>
02#include<conio.h>
03#include<graphics.h>
04#include<dos.h>
05void main()
06{
07int gd=DETECT,gm,i=-300,j;
08int poly[16]={100,100,250,100,250,50,300,50,325,90,325,140,100,140,100,100};
09int tpoly[16]={100,100,250,100,250,50,300,50,325,90,325,140,100,140,100,100};
10initgraph(&gd,&gm,"");
11getch();
12while(!kbhit())
13{
14for(j=0;j<16;j+=2)
15{
16poly[j]=tpoly[j]+i;
17}
18fillpoly(8,poly);
19setfillstyle(5,7);
20bar(275+i,60,295+i,85);
21setfillstyle(5,8);
22fillellipse(140+i,140,20,20);
23fillellipse(280+i,140,20,20);
24setfillstyle(1,0);
25fillellipse(140+i,140,10,10);
26fillellipse(280+i,140,10,10);
27setcolor(15);
28line(0,160,639,160);
29setcolor(0);
30setfillstyle(1,4);
31delay(20);
32cleardevice();
33i++;
34if(i>550)
35i=-300;
36}
37closegraph();
38}

Output:

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Web Hosting Coupons