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