ANIM.C

 /************************************************************************/
/* Animated Text */
/* ÄÄÄÄÄÄÄÄÄÄÄÄÄ */
/* - anim_mat -> animate the text giving the matrix type effect */
/************************************************************************/

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>

void anim_mat(char *str,char x,char y,char col,char speed);
void anim(char *ch,char x,char y,char ctr,char t,char *speed);
void atext(char *str,char x,char y,char *speed);

void anim_mat(char *str,char x,char y,char col,char speed)
{
char ctr;
struct text_info ti;

gettextinfo(&ti); // getting the screen info

_setcursortype(0);  // hide the cursor
textcolor(col);     // set the given color

atext(str,x+1,y,&speed); // call of the animated text function

textattr(ti.attribute); // restoring the text attributes
gotoxy(ti.curx,ti.cury); // restoring the cursor position
_setcursortype(2); //show the underscore cursor

return;
}
void atext(char *str,char x,char y,char *sp)
{
static char ctr=0,size;

size=strlen(str);  // size of the string

if(*str == '\0')
return;
else
{
anim(str,x,y,0,size-ctr,sp); // calling func to anim a char
atext(++str,++x,y,sp); // recursive call for next char
}
return;
}
#define TCK 4
char test;
void anim(char *ch,char x,char y,char ctr,char t,char *sp)
{
// t=(t>TCK?TCK:t);
if(ctr == TCK) // TCK -> no of times blinks
{
gotoxy(x,y);
cprintf("%c",*ch); //printing the char
for(test=0;test<t-1;test++)   // Priting the
cprintf("%c",random(26)+65);  //   other junk chars
delay(50/ *sp);  // delay as per speed
return;
}
else if(ctr < TCK)
{
gotoxy(x,y);
for(test=0;test<t;test++)    //  Priting the junk
cprintf("%c",random(26)+65); //    chars for before last time
delay(50/ *sp);    // delay as per speed
anim(ch,x,y,ctr+1,t,sp);  // recursive call for next movement
}
return;
}

Project Homepage: