abcdef

#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
using namespace std;
int d[1000][1000];
int mark=0;
int big=0;
int fast=1;
int fastn=0;
int mx2=0;
int my2=0;
int ice=0;
int icen=0;
int sel;
void gotoxy(int x, int y) {
	// 获取标准输出句柄
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	// 设置光标位置
	COORD pos = {x, y};
	SetConsoleCursorPosition(hStdout, pos);
}


void Colour(int a) {
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}//0黑 1蓝 2绿 3青 4红 5紫 6黄 7白 8灰 9亮蓝 10亮绿 12亮红 15亮白

void Sl(string a){
	for(int i=0;i<a.size();i++){
		cout<<a[i];
		Sleep(20);
	}
	cout<<"\n";
}

void Backspace(int a) {
	for(int i=1; i<=a; i++) {
		cout<<"\b \b";
	}
}

int SJS(int a,int b) {
	int lowerBound = a;
	int upperBound = b;
	srand(time(0));
	int randomNum = rand() % (upperBound - lowerBound + 1) + lowerBound;
	return randomNum;
}


void meun(){
x4:	system("cls");

	Colour(7);
	Sl("1.开始游戏");
	Sl("2.查看规则");
	gotoxy(10,0);
	cout<<"<-";
	while(true){
		int key=_getch();
		if(key==0||key==224){
			key=_getch();
			fflush(stdin);
			int ly=0;
			int ny=1;
			if(key==72){
				ly=sel;
				if(sel>0) sel--;
				else sel==0;
				ny=sel;
				sel==0;
			}
			else if(key==80){
				ly=sel;
				if(sel<1) sel++;
				else sel==1;
				ny=sel;
			}
			gotoxy(10,ly);
			cout<<"    ";
			gotoxy(10,ny);
			cout<<"<-";
		}
		else if(key==13) break;
	}
	Colour(7);


}
int main() {
	ShowCursor(TRUE);

	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO cci;
	cci.dwSize = 30; // 光标大小
	cci.bVisible = FALSE; // 设置光标不可见
	SetConsoleCursorInfo(hOut, &cci);
x3:	meun();
	if(sel==0) goto x1;
	else if(sel==1){
		Colour(7);
		system("cls");
		cout<<"                                                                             规则介绍\n";
		cout<<"一.操作说明\n\n";
		cout<<"  (1).W/A/D/S进行移动\n\n";
		cout<<"二.玩法指南\n\n";
		cout<<"  (1).会有怪物追你(25%的概率),怪物为:  ";

		Colour(2);
		cout<<"&\n\n";
		Colour(7);
		//普通豆子
		cout<<"  (2). ";
		Colour(6);
		cout<<"\"*\" ";
		Colour(7);
		cout<<"普通豆子,分值5\n\n";
		//加速豆子
		cout<<"  (3). ";
		Colour(6);
		cout<<"\"●\" ";
		Colour(7);
		cout<<"加速豆子,分值10并加速\n\n";
		//寒冰豆子
		cout<<"  (4). ";
		Colour(9);
		cout<<"\"*\" ";
		Colour(7);
		cout<<"寒冰豆子,分值5并冻住怪物50游戏刻\n\n";

		Colour(7);
		system("pause");
		goto x3;
	}
x1:	system("cls");

	Colour(7);
	cout<<"分数:";
	Colour(4);
	cout<<mark<<"      ";
	Colour(7);

	cout<<"历史最高分数:";
	Colour(4);
	cout<<big<<"      ";
	Colour(7);

	cout<<"冰冻时间:";
	Colour(9);
	cout<<icen<<"      ";


	Colour(7);
	gotoxy(1,3);
	for(int i=1; i<=156; i++) cout<<"=";
	cout<<"\n";
	int mx=SJS(1,199),my=SJS(5,20);
	gotoxy(mx,my);
	Colour(2);
	cout<<"&";


	int x=10,y=10;
	gotoxy(x,y);
	Colour(1);
	cout<<"@";
	int a=SJS(1,120),b=SJS(5,20);
	gotoxy(a,b);
	d[a][b]=1;
	Colour(6);
	cout<<"*";
	int i;
	while(true) {
		Colour(1);
		fflush(stdin);
		char key=_getch();
		if(key==27) {
			Colour(7);
			goto x3;//ESC

		}
		gotoxy(x,y);
		cout<<' ';
		if(key=='w'&&y>=5) y--;
		else if(key=='s'&&y<=30) y++;
		else if(key=='a'&&x>=2) x--;
		else if(key=='d'&&x<=199) x++;
		fflush(stdin);
		gotoxy(x,y);//按键控制
		cout<<"@";
		int sjs;
		sjs=SJS(5,25);
		if(sjs==5 || sjs==7 || sjs==11 || sjs==19 || sjs==17) {
			int dx=SJS(1,119);
			int dy=SJS(6,30);
			gotoxy(dx,dy);
			Colour(6);
			sjs=SJS(1,4);
			if(sjs==3){
				sjs=SJS(1,10);

				if(sjs%3==0){
					cout<<"●";
					d[dx][dy]=2;
				}
				else{
					Colour(9);
					cout<<"*";
					d[dx][dy]=3;
				}
			}

			else{
				cout<<"*";
				d[dx][dy]=1;
			}
		}
		if(d[x][y]==1) {
			mark+=5;
			Beep(800,100);
			gotoxy(0,0);
			Colour(7);
			cout<<"分数:";
			Colour(4);
			cout<<mark;
			gotoxy(x,y);
			d[x][y]=0;
		}
		else if(d[x][y]==2){
			mark+=10;
			Beep(800,100);
			gotoxy(0,0);
			Colour(7);
			cout<<"分数:";
			Colour(4);
			cout<<mark;
			gotoxy(x,y);
			d[x][y]=0;
			fast=2;
			fastn=100;
		}
		else if(d[x][y]==3){
			mark+=5;
			Beep(800,100);
			gotoxy(0,0);
			Colour(7);
			cout<<"分数:";
			Colour(4);
			cout<<mark;
			gotoxy(x,y);
			d[x][y]=0;
			ice=1;
			icen=51;
		}
		gotoxy(mx,my);
		cout<<" ";
		sjs=SJS(1,100);
		if(sjs%(4*fast)==0 && icen==0){

			if(mx>x) mx--;
			if(mx<x) mx++;
			if(my>y) my--;
			if(my<y) my++;
		}


		gotoxy(mx,my);
		if(icen==0){
			Colour(2);
		}
		else{
			Colour(9);
		}

		cout<<"&";
		gotoxy(x,y);

		if(mx==x && my==y && icen==0) {
			system("cls");
			Colour(7);
			for(int i=1; i<=15; i++) {
				cout<<"\n";
			}
			for(int i=1; i<=30; i++) {
				cout<<"  ";
			}
			Colour(4);
			cout<<"GAME OVER";
			if(mark>=big) big=mark;
			mark=0;
			fflush(stdin);
			Sleep(500);
			fflush(stdin);
			Colour(7);
			fflush(stdin);
			for(int i=1; i<=50; i++) {
				cout<<"  ";
			}
			cout<<"\n";
			fflush(stdin);
			system("pause");
			goto x3;
		}
		fastn--;
		if(fastn==0){
			fast=1;
		}
		if(icen>0)icen--;
		if(icen==0){
			ice==0;
		}
		gotoxy(44,0);
		cout<<"    ";
		gotoxy(44,0);
		Colour(9);
		cout<<icen;
		Sleep(50/fast);
	}
}

此话题已在最后回复的 15 天后被自动关闭。不再允许新回复。