Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples C
 

Glittering Eyes - Animation Effect


Code ResourceAuthor: sripri  

Difficulty Level:

Published: 24th May 2007   Read: 2893 times  

Filed in: C
Add Comment


 


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: Swap 2 variables without using 3rd variable


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





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. kaivalya198914897
2. chandrikakr4781
3. meefriend4ever3547
4. sripri2894
5. deepu082813
6. Jimmy Zorald2564
7. Rajani1630
8. norman1442
9. reliable1097

Active Coders

# Coder NameCodes
1. kaivalya19894
2. sripri1
3. Jimmy Zorald1
4. norman1
5. Rajani1
6. meefriend4ever1
7. chandrikakr1
8. reliable1
9. deepu081

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape