Home Forums C Programming animation Reply To: animation

#3227
will
Participant

Hello
Here is a portion of a program for “Bank managgement system” which I worte while I was in my Bachelors of IT. To make an animation in C Language you will need to create the image at run time and move that image on the screen. What i have done is created a bitmap using circles, arcs & different colors, and tried to make some sort of a logo, then put the whole graphics area in an image using getimage() function & used putimage() to show the image on the screen. To make an animation in C Language I have put this image in a loop which animates the image  on the screen in scrolling mode.

 for(int count=1;count<300;count+=2){
    putimage(1+count,100,image,COPY_PUT);
}

 
Also I have made another animation which makes a complete line from a single point.

for(int down=0;down<640;++down)
 {
    delay(5);
    line(1,220,1+down,220);
 }

 
And at the end I have made another animation effect using the line() function again.

for(int bottom=0;bottom<300;bottom+=4)
  line(1,220+bottom,640,220+bottom);

 
Below is the main source code of the complete animation. You can modify it according to your needs.
 

#include
#include
#include
#include
#include
#include
#include
#include
void main(void){
 void *image;
 int size;
 int dr=9,mode=2;
 initgraph(&dr,&mode,"..\bgi");
 size=imagesize(140,140,500,250);
 image=malloc(size);
 setfillstyle(SOLID_FILL,GREEN);
 circle(200,200,50);
 floodfill(200,200,WHITE);
 setcolor(LIGHTGRAY);
 circle(200,200,19);
 setcolor(WHITE);
 circle(200,200,18);
 circle(200,200,49);
 circle(200,200,53);
 circle(200,200,20);
 
 arc(215,215,350,90,30);
 arc(210,182,90,194,30);
 arc(180,195,180,300,30);
 settextstyle(1,HORIZ_DIR,1);
 setcolor(LIGHTGRAY);
 outtextxy(270,180,"National Bank");
 
 outtextxy(270,185,"___________________");
 outtextxy(270,210,"Of Pakistan Pvt Ltd.");
 settextstyle(0,HORIZ_DIR,0);
 setcolor(DARKGRAY);
 outtextxy(270,240,"COPYRIGHT 2002");
 getimage(141,141,499,259,image);
 cleardevice();
 for(int count=1;count<300;count+=2)
  putimage(1+count,100,image,COPY_PUT);
 for(int down=0;down<640;++down)
 {
  delay(5);
  line(1,220,1+down,220);
 }
 setcolor(BLUE);
 for(int bottom=0;bottom<300;bottom+=4)
  line(1,220+bottom,640,220+bottom);
 free(image);
 getch();
 closegraph();
}