#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<bios.h>
#define L 0x4b00
#define R 0x4d00
#define U 0x4800
#define D 0x5000
#define ESC 0x11b
int X=0,Y=0;
unsigned KEY;
char MENU[4][3][6]={{"str00\0","str01\0","str02\0"},{"str10\0","str11\0","str12\0"},{"str20\0","str21\0","str22\0"},{"str30\0","str31\0","str32\0"}};
void main()
{
void draw(int a,int b,int sign);
void crtview(void);
void draw1(int a,int b,int sign);
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"d:\\tc2");
setbkcolor(EGA_BLUE);
setfillstyle(SOLID_FILL,EGA_WHITE);
bar(0,0,639,19);
bar(0,459,639,479);
setcolor(EGA_WHITE);
rectangle(4,24,634,454);
setcolor(EGA_BLUE);
outtextxy(249,464,"MADE BY ZY");
getch();
for(X=0,Y=0;X<=3;X++)
draw(X,Y,EGA_WHITE);
X=0;
Y=0;
draw(X,Y,EGA_RED);
while(1)
{
KEY=bioskey(0);
switch(KEY)
{
case L:
if(X==0)break;
else
{
if(Y!=0)
{
clearviewport();
setcolor(EGA_WHITE);
line(-5,4,634,4);
Y=0;
graphdefaults();
setbkcolor(EGA_BLUE);
}
draw(X,Y,EGA_WHITE);
X--;
draw(X,Y,EGA_RED);
}
break;
case R:
if(X==3)break;
else
{
if(Y!=0)
{
clearviewport();
setcolor(EGA_WHITE);
line(-5,4,634,4);
Y=0;
graphdefaults();
setbkcolor(EGA_BLUE);
}
draw(X,Y,EGA_WHITE);
X++;
draw(X,Y,EGA_RED);
break;
}
case U:
if(Y==0)break;
else
{ if(Y==2)
{
draw1(X,Y,EGA_WHITE);
Y--;
draw1(X,Y,EGA_GREEN);
break;
}
else
break;
}
case D:
if(Y==2)break;
else
{
if(Y==0)
{
crtview();
break;
}
else
{
draw1(X,Y,EGA_WHITE);
Y++;
draw1(X,Y,EGA_GREEN);
break;
}
}
case ESC:
closegraph();
return;
default:
break;
}
}
}
void draw(int a,int b,int sign)
{
setfillstyle(SOLID_FILL,sign);
bar(49+a*100,0,49+(a+1)*100,19);
if(sign==EGA_WHITE)
sign=EGA_RED;
else
sign=EGA_WHITE;
setcolor(sign);
outtextxy(49+a*100,5,MENU[a][b]);
}
void crtview(void)
{
setviewport(49+X*100,20,149+X*100,20*3,1);
setfillstyle(SOLID_FILL,EGA_WHITE);
bar(0,0,99,39);
for(Y=1;Y<=2;Y++)
draw1(X,Y,EGA_WHITE);
Y=1;
draw1(X,Y,EGA_GREEN);
}
void draw1(int a,int b,int sign)
{
setfillstyle(SOLID_FILL,sign);
bar(0,(Y-1)*20,100,Y*20);
if(sign==EGA_WHITE)
sign=EGA_RED;
else
sign=EGA_BLUE;
setcolor(sign);
outtextxy(0,5+(b-1)*20,MENU[a][b]);
}
这个程序错在哪了呢?