Code.GeekInterview.com
 
Code Samples C
 

Glittering Eyes - Animation Effect


Code ResourceAuthor: sripri  

Difficulty Level:

Published: 24th May 2007   Read: 5432 times  

Filed in: C
Add Comment


 

 

Sponsored Links


 

 

This program written in C using graphics gives a simple animation effect and displays glittering eyes with a colorful welcome message. This program has just 92 lines of code. Try out this program in Turbo.C where the header file graphics.h is present.

 


Sample Code
  1.  
  2. # include <graphics.h>
  3. # include <conio.h>
  4. # include <stdio.h>
  5. main()
  6. {
  7.  int gm,gd=DETECT;
  8.  int a,b,c;
  9.  int i,j;
  10.  int color, n, m;
  11.  initgraph(&gd,&gm,"");
  12.  for(m=0; m<5; m++)
  13.    {
  14.       i=2;
  15.       j=2;
  16.       for(n=0; n<100; n++)
  17.       {
  18.          putpixel(i+m,j,RED);
  19.          i=i+10;
  20.       }
  21.     }
  22.     for(m=0;m<5;m++)
  23.     {
  24.       j=2;
  25.       i=2;
  26.       for(n=0;n<100;n++)
  27.       {
  28.         putpixel(i,j+m,RED);
  29.         j=j+10;
  30.       }
  31.     }
  32.     for(m=0;m<5;m++)
  33.     {
  34.       j=633;
  35.       i=633;
  36.       for(n=0;n<100;n++)
  37.       {
  38.         putpixel(i,j-m,RED);
  39.         j=j-10;
  40.       }
  41.     }
  42.     for(m=0;m<5;m++)
  43.     {
  44.       i=673;
  45.       j=473;
  46.       for(n=0;n<100;n++)
  47.       {
  48.         putpixel(i+m,j,RED);
  49.         i=i-10;
  50.       }
  51.     }
  52.  setcolor(EGA_RED);
  53.  moveto(255,50);
  54.  settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
  55.  textcolor(BLUE+BLINK);
  56.  outtext("WELCOME");
  57.  getaspectratio(&a,&b);
  58.  c=a;
  59.    circle(270,200,16);
  60.    circle(370,200,16);
  61.    arc(320,250,180,0,10);
  62.    line(275,180,320,150);
  63.    line(365,180,320,150);
  64.  while(!kbhit())
  65.  {
  66.    a=c;
  67.    setcolor(EGA_YELLOW);
  68.    while(1)
  69.    {
  70.      setaspectratio(a,b);
  71.      circle(270,200,15);
  72.      putpixel(270,200,EGA_RED);
  73.      circle(370,200,15);
  74.      putpixel(370,200,EGA_RED);
  75.      a=a-20;
  76.      if(a<=1) break;
  77.    }
  78.   setcolor(EGA_BLACK);
  79.   while(1)
  80.   {
  81.     setaspectratio(a,b);
  82.     circle(270,200,15);
  83.     putpixel(270,200,YELLOW);
  84.     circle(370,200,15);
  85.     putpixel(370,200,YELLOW);
  86.     a=a+20;
  87.     if(a>=c-50)
  88.     break;
  89.   }
  90. }
  91.  getch();
  92.  closegraph();
  93.  }
  94.  
Copyright GeekInterview.com


Next: Basic Memory Management


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

The program was exciting. A very good colorful program that reflected the usage of graphics in C and setaspectratio feature of C program very nicely in a simple effective program. Thanks for making such wonderful program posts.
Comment posted by: William on 2007-05-26T23:40:58
The program was exciting. A very good colorful program that reflected the usage of graphics in C and setaspectratio feature of C program very nicely in a simple effective program. Thanks for making such wonderful program posts.
Comment posted by: Williamj on 2007-05-26T23:25:53

Popular Coders

# Coder NameHits
1. kaivalya198932319
2. mano.mithun19252
3. deepu0817247
4. meefriend4ever7825
5. chandrikakr7816
6. shashivaishnav6687
7. sadasivathavamani6567
8. venkatakrishnansvpr6441
9. Jimmy Zorald6278
10. sripri5433

Active Coders

Refined Tags