谁看看这个迷宫游戏哪错了?
#include "stdio.h"#include "conio.h"
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
#define ESC 27
#define N 10
#define M 10
union keyboard
{
int iKey;
char chKey[2];
};
void print_welcome(int *name);
void print_maze(int *maps[10]);
int GetKey(void);
int main(void)
{
int name[10];
int key,x=36,y=13;
int map1[N][M]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,1,0,0,0,1},
{1,0,1,1,0,0,0,1,0,0},
{1,0,0,1,1,1,1,1,1,1},
{1,0,1,1,0,0,1,1,0,1},
{1,0,0,0,1,0,0,0,0,1},
{1,1,1,0,1,1,1,0,1,1},
{1,0,0,0,1,0,0,0,1,1},
{1,0,1,0,0,0,1,0,0,1},
{1,1,1,1,1,1,1,1,1,1}
};
print_welcome(name);
clrscr();
gotoxy(0,0);
printf("Name:%s",name);
gotoxy(x,y);
print_maze(map1[N][M]);
gotoxy(x,y);
cprintf("%c\b",2);
key=GetKey();
if(key==LEFT &&map1[y-5][x-1-35]!=1) x--;
if(key==RIGHT&&map1[y-5][x+1-35]!=1) x++;
if(key==UP&&map1[y-1-5][x-35]!=1) y--;
if(key==DOWN &&map1[y+1-5][x-35]!=1) y++;
if(x==44&&y==7)
{
clrscr();
gotoxy(35,10);
textcolor(YELLOW);
cprintf("You Win!");
exit(0);
}
if(key==ESC)
{
clrscr();
gotoxy(35,10);
textcolor(YELLOW);
cprintf("You lose!");
exit(0);
}
getch();
return 0;
}
void print_welcome(int *name)
{
int i;
textcolor(YELLOW);
cprintf("Welcome to Game\n");
cprintf("Enter your Role Name:");
gets(name);
}
void print_maze(int *maps[])
{
int i,j;
while(1)
{
for(i=0;i<10;i++)
{
gotoxy(35,5+i);
for(j=0;j<10;j++)
{
if(maps[i][j]==0)printf(" ");
if(maps[i][j]==1)printf("#");
}
}
}
}
int GetKey(void)
{
union keyboard Key1;
while(bioskey(1)==0);
Key1.iKey=bioskey(0);
return(Key1.chKey[0]==0?Key1.chKey[1]:Key1.chKey[0]);
}
运行输入游戏名称之后 光标就乱跳。哪里错了?