开发者

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);
    }

matrix sort of graphics in C


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,"     ");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜