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.

114 lines
1.9 KiB

This file contains ambiguous Unicode characters!

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<stdio.h>
#include<windows.h>
#include<stdlib.h>
void welcome();
int color(int c)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);//更改文字颜色
return 0;
}
/*****获取屏幕光标位置*******/
static void gotoxy(int x, int y){
COORD point = { x, y };//光标要设置的位置x,y
HANDLE HOutput = GetStdHandle(STD_OUTPUT_HANDLE);//使用GetStdHandle(STD_OUTPUT_HANDLE)来获取标准输出的句柄
SetConsoleCursorPosition(HOutput, point);//设置光标位置
}
//生成进入界面
void title()
{
color(14);
gotoxy(30,7);
printf("欢迎来到");
color(5);
gotoxy(36,8);
printf("迷宫游戏");
}
void ajsm()
{
int n;
color(8);
gotoxy(30,9);
printf("键盘‘↑’、‘↓’、‘←’、‘→’控制");
gotoxy(30,10);
printf("按1继续按2退出:[ ](按回车进入)\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%d",&n);
switch(n)
{
case 1:
system("cls");
welcome();
break;
case 2:
exit(0);
}
}
void yxgz()
{
int n;
color(2);
gotoxy(30,9);
printf("控制你的小点来避开所有障碍,并到达最终终点吧!");
gotoxy(30,10);
printf("按1继续按2退出:[ ](按回车进入)\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%d",&n);
switch(n)
{
case 1:
system("cls");
welcome();
break;
case 2:
exit(0);
}
}
void welcome()
{
title();
int i,j=1;
color(9);
for(i=9;i<=20;i++){
for(j=15;j<=60;j++){
gotoxy(j,i);
if(i==9||i==20) printf("=");
else if(j==15||j==59) printf("::");
}
}
int n;
color(12);
gotoxy(25,12);
printf("1.开始游戏");
gotoxy(40,12);
printf("2.按键说明");
gotoxy(25,17);
printf("3.游戏规则");
gotoxy(40,17);
printf("4.退出");
gotoxy(21,22);
printf("请选择[1,2,3,4]:[ ](按回车进入)\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
scanf("%d",&n);
switch(n)
{
case 1:
system("cls");
break;
case 2:
system("cls");
ajsm();
break;
case 3:
system("cls");
yxgz();
break;
case 4:
exit(0);
break;
}
}
int main(void)
{
welcome();
return 0;
}