You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <time.h>
# define Height 25 //迷宫的高度
# define Width 25 //迷宫的宽度
# define Wall 1
# define Road 0
# define Start 2
# define End 3
# define Esc 5
# define Up 1
# define Down 2
# define Left 3
# define Right 4
static int flag = 0 , hei = 0 ; //旗帜们
static int a = 51 , b = 5 ; //'嘟'叫声的坐标
int map [ Height + 2 ] [ Width + 2 ] ;
void gotoxy ( int x , int y ) //移动坐标
{
COORD coord ; /*COORD实际上是一个C语言内部做好的结构体*/
coord . X = x ;
coord . Y = y ; //SetConsoleCursorPosition这个函数是用来移动光标的, 也是由C语言直接提供给你的直接使用就可以。
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ) , coord ) ;
} //GetStdHandle(STD_OUTPUT_HANDLE)这里就是一个固定的函数格式,获得标准输出函数的句柄。
void hidden ( ) //隐藏光标
{
HANDLE hout = GetStdHandle ( STD_OUTPUT_HANDLE ) ; //GetStdHandle( ) 这个函数也是C语言内部已经设定好的, 所以这里直接调用就行。
CONSOLE_CURSOR_INFO cci ;
GetConsoleCursorInfo ( hout , & cci ) ;
cci . bVisible = 0 ; //赋1为显示, 赋0为隐藏
SetConsoleCursorInfo ( hout , & cci ) ;
}
int main ( )
{
system ( " color F3 " ) ;
out : //通关后可重置迷宫, goto在最后几行
int i , j ;
char k ;
flag = 0 , hei = 0 ; a = 51 , b = 5 ;
system ( " title 始乱幻阵 " ) ;
gotoxy ( 51 , 0 ) ;
printf ( " 伟大的勇者,在这个始末幻阵,一旦踏入, 便无回首,望你于此阵中得道,集大成而无敌。 " ) ;
gotoxy ( 51 , 2 ) ;
printf ( " I: 进入? 按空格吧~ \n II: 否则请'ESC'咯~ " ) ;
k = getch ( ) ;
if ( k = = ' ' ) {
gotoxy ( 51 , 4 ) ;
printf ( " OK~~ " ) ;
}
else
{
gotoxy ( 51 , 4 ) ;
printf ( " Goodbye! ! " ) ;
return 0 ;
}
hidden ( ) ; //隐藏光标
getch ( ) ;
return 0 ;
}