int
delay=200; //蛇每delay个时间走一步
void main()
{
LOOP:
system("cls");
system("color 9");
init();
create_window();
hidden();
create_food();
while(1)
{
int i;
Sleep(delay);
direction();
eat();
show_snake();
update_maxtrix();
state();
if(liv_stat==1)
{
for(i=1;i<snake_len;i++)
{
gotoxy(snake_loc[i][0],snake_loc[i][1]);
printf(" ");
}
gotoxy(food[0],food[1]);
printf(" ");
gotoxy(30,12);
printf("Game over!\n");
gotoxy(25,13);
printf("继续请按y,退出请按n");
while(1)
{
i=getch();
if(i=='y')goto LOOP;
else if(i=='n')break;
}
break;
}
}
}