matrix sort of graphics in C
I am making a program with graph开发者_StackOverflowics.h in C.I am trying to implement the matrix screen saver but I am stuck here in the code.The alphabets fall just once.I want them to keep on falling (removing the text before).Please guide me how to clear the old contents
void main_page(void)
{
int i,j,k,l,m,n,size;
setcolor(BLUE);
for(i=0;i<500;i+=50)
{
settextstyle(GOTHIC_FONT,1,1);
outtextxy(50,50+i,"a b c");
outtextxy(100,150+i,"H I J");
outtextxy(150,250+i,"X Y Z");
outtextxy(300,50+i,"D E F");
outtextxy(350,350+i,"D E F");
outtextxy(400,350+i,"D E F");
outtextxy(450,350+i,"D E F");
outtextxy(500,50+i,"D E F");
outtextxy(550,350+i,"D E F");
outtextxy(600,350+i,"D E F");
delay(100);
}
Don't you have to erase or over-write the characters in the old locations? So you might do it bottom-up rather than top-down, and, last, finally print some blanks?
ADDED: Well, here's a really brute-force way to do it, that I don't like. Replace the code inside your loop with this:
settextstyle(GOTHIC_FONT,1,1);
outtextxy( 50, 50+i,"a b c");
outtextxy(100,150+i,"H I J");
outtextxy(150,250+i,"X Y Z");
outtextxy(300, 50+i,"D E F");
outtextxy(350,350+i,"D E F");
outtextxy(400,350+i,"D E F");
outtextxy(450,350+i,"D E F");
outtextxy(500, 50+i,"D E F");
outtextxy(550,350+i,"D E F");
outtextxy(600,350+i,"D E F");
delay(100);
outtextxy( 50, 50+i," ");
outtextxy(100,150+i," ");
outtextxy(150,250+i," ");
outtextxy(300, 50+i," ");
outtextxy(350,350+i," ");
outtextxy(400,350+i," ");
outtextxy(450,350+i," ");
outtextxy(500, 50+i," ");
outtextxy(550,350+i," ");
outtextxy(600,350+i," ");
精彩评论