跳到正文

个人记录

小游戏 · 19 蒟蒻的找物品游戏

xutongwei约 40 分钟
原文
文章信息与版本

文章信息

发布
2020年3月27日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 40 分钟

版本

  1. v1当前
C++
#include <iostream>
#include <cstring>
#include <cmath>
#include <conio.h>
#include <windows.h>
#include <ctime>
using namespace std;

bool r1 = false, r2 = false, r3 = false;
int m1 = 1, m2 = 0, m3 = 1;
int wu[11][3], wul = 0;
int zha = 0, cuo = 0;
int map[41][61];
int shicha = 0;
int n = 10, m = 10, x = 5, y = 5, cx = 5, cy = 5;
char m33[6][6] = {{' '}, {' ', 'w', 's', 'a', 'd', 'k'}};
int m334[6] = {0, 15};
int x3[6], y3[6], zha3[6], cuo3[6], cx3[6], cy3[6], m34[6], m44[6], m344 = 6;

void color(int a){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}

void HideCursor(){
    CONSOLE_CURSOR_INFO cursor_info = {1, 0}; 
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}

void block(int x,int y){
    HANDLE   hCon;
    hCon = GetStdHandle(STD_OUTPUT_HANDLE);  
    COORD   setps;
    setps.X = x;
    setps.Y = y;
    SetConsoleCursorPosition(hCon,setps);  
}

int rand1(int x, int y){
	srand(time(NULL));
	int sui = rand() % 2147483647;
	sui = ((((((sui / 23 - shicha) * 19 + shicha) >> 5) << 4 - shicha) / 29) * 37 + shicha) / 43;
	srand(sui + time(NULL) - shicha);
	return (rand() % (y - x + 1)) + x;
}

int rand2(int x, int y){
	srand(time(NULL));
	srand(rand() % 65535 + shicha);
	srand(rand() % 65535 + time(NULL));
	srand(rand() % 65535 - shicha);
	return (rand() % (y - x + 1)) + x;
}

void output0_1(){
	system("cls");
	cout << "普通游戏:" << endl;
	cout << "    1.开始游戏!" << endl;
	if(r1){
		cout << "    2.模式:箭头" << endl;
	}else{
		cout << "    2.模式:普通" << endl;
	}
	if(r2){
		cout << "    3.模式:多物品" << endl;
	}else{
		cout << "    3.模式:单物品" << endl;
	}
	if(r3){
		cout << "    4.模式:有炸弹" << endl;
	}else{
		cout << "    4.模式:无炸弹" << endl;
	}
	cout << "    5.查看规则" << endl;
	cout << "    0.退出" << endl;
}

void output0_2(){
	system("cls");
	cout << "自定义游戏:" << endl;
	cout << "    1.开始游戏!" << endl;
	if(r1){
		cout << "    2.模式:箭头" << endl;
	}else{
		cout << "    2.模式:普通" << endl;
	}
	cout << "    3.面积:" << n << "*" << m << endl;
	cout << "    4.物品数:" << m1 << endl;
	cout << "    5.炸弹数:" << m2 << endl;
	cout << "    6.玩家操作:" << endl;
	for(int i = 1; i <= m3; i++){
		cout << "      ";
		color(m334[i]);
		cout << "玩家" << i << ":";
		color(15);
		cout << m33[i][1] << " " << m33[i][2] << " " << m33[i][3] << " " << m33[i][4] << " " << m33[i][5] << endl;
	}
	cout << "    0.退出" << endl;
}

void play1(){
	system("cls");
	cout << "请选择难度:" << endl;
	cout << "    1.简单" << endl;
	cout << "    2.适中" << endl;
	cout << "    3.困难" << endl;
	cout << "    4.超难" << endl;
	p2:char zzz2 = getch();
	if(zzz2 == '1'){
		n = 8;
		m = 8;
		x = 4;
		y = 4;
		if(r2){
			m1 = 2;
		}
		if(r3){
			m2 = 5;
		}
		system("mode con cols=24 lines=14");
	}else if(zzz2 == '2'){
		n = 15;
		m = 15;
		x = 8;
		y = 8;
		if(r2){
			m1 = 3;
		}
		if(r3){
			m2 = 15;
		}
		system("mode con cols=38 lines=21");
	}else if(zzz2 == '3'){
		n = 20;
		m = 30;
		x = 10;
		y = 15;
		if(r2){
			m1 = 5;
		}
		if(r3){
			m2 = 30;
		}
		system("mode con cols=68 lines=26");
	}else if(zzz2 == '4'){
		n = 30;
		m = 50;
		x = 15;
		y = 25;
		if(r2){
			m1 = 8;
		}
		if(r3){
			m2 = 50;
		}
		system("mode con cols=108 lines=36");
	}else{
		goto p2;
	}
	map[x][y] = -1;
}

void play2(){
	cuo = zha = wul = 0;
	memset(map, 0, sizeof(map));
	memset(wu, 0, sizeof(wu));
	int i1 = m1;
	for(int i = 0; i < i1; i++){
		if(shicha > 65536){
			shicha -= 65536;
		}else{
			shicha += rand1(11, 29);
		}
		int sui1 = rand2(0, (n - 1) * (m - 1));
		int x1 = sui1 % n + 1;
		int y1 = sui1 / (n - 1) % m + 1;
		if(map[x1][y1] != 0){
			i1++;
			continue;
		}else{
			map[x1][y1] = 1;
			wul++;
			wu[wul][1] = x1;
			wu[wul][2] = y1;
		}
	}
	i1 = m2;
	for(int i = 0; i < i1; i++){
		if(shicha > 65536){
			shicha -= 65536;
		}else{
			shicha += rand1(11, 29);
		}
		int sui1 = rand2(0, (n - 1) * (m - 1));
		int x1 = sui1 % n + 1;
		int y1 = sui1 / (n - 1) % m + 1;
		if(map[x1][y1] != 0){
			i1++;
			continue;
		}else{
			map[x1][y1] = 2;
		}
	}
}

void play(){
	m1 = 1;
	m2 = 0;
	play1();
	play2();
	system("cls");
	cout << "游戏开始!" << endl;
	Sleep(2500);
	system("cls");
	Sleep(500);
	color(15);
	for(int j = 1; j <= m; j++){
		block(j * 2 + 4, 2);
		cout << "—";
		block(j * 2 + 4, n + 3);
		cout << "—";
	}
	for(int i = 1; i <= n; i++){
		block(4, i + 2);
		cout << "| ";
		block(m * 2 + 5, i + 2);
		cout << " |";
	}
	block(4, 2);
	cout << "╭";
	block(m * 2 + 5, 2);
	cout << "╮";
	block(4, n + 3);
	cout << "╰";
	block(m * 2 + 5, n + 3);
	cout << "╯";
	if(m3 > 0){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				if(map[i][j] == 2){
					block(j * 2 + 4, i + 2);
					color(12);
					cout << "¤";
				}
			}
		}
		color(15);
		block(2, n + 4);
		cout << "请先记住炸弹的位置。";
		Sleep(1500);
		block(2, n + 4);
		cout << "                    ";
		block(2, n + 4);
		system("pause");
		block(2, n + 4);
		cout << "                    ";
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				block(j * 2 + 4, i + 2);
				cout << "  ";
			}
		}
	}
	color(15);
	bool h = false;
	cx = x;
	cy = y;
	while(true){
		bool h1 = false;
		if(wul == 0){
			h = true;
			break;
		}
		if(zha >= 3 || cuo >= 3){
			break;
		}
		block(2, 1);
		cout << "剩余物体数:" << wul;
		if(r1){
			block(y * 2 + 4, x + 2);
			int i2 = 1;
			while(wu[i2][0] != 0){
				i2++;
			}
			if(wu[i2][1] > x){
				if(wu[i2][2] > y){
					cout << "↘";
				}else if(wu[i2][2] == y){
					cout << "↓";
				}else{
					cout << "↙";
				}
			}else if(wu[i2][1] == x){
				if(wu[i2][2] > y){
					cout << "→";
				}else if(wu[i2][2] == y){
					cout << "㊣"; 
				}else{
					cout << "←";
				}
			}else{
				if(wu[i2][2] > y){
					cout << "↗";
				}else if(wu[i2][2] == y){
					cout << "↑";
				}else{
					cout << "↖";
				}
			}
		}else{
			block(y * 2 + 4, x + 2);
			int sum1 = 0;
			for(int i = 1; i <= m1; i++){
				if(wu[i][0] == 0){
					sum1 += (abs(x - wu[i][1]) + abs(y - wu[i][2]));
				}
			}
			double sum2 = 1.00 * sum1 / wul;
			if(sum2 <= 2.0){
				cout << "▇";
			}else if(sum2 <= 5.0){
				cout << "▅";
			}else if(sum2 <= 10.0){
				cout << "▃";
			}else{
				cout << "▁";
			}
		}
		char zzz3 = getch();
		if(zzz3 == 'W' || zzz3 == 'w'){
			if(x > 1){
				x--;
			}
			h1 = true; 
		}else if(zzz3 == 'S' || zzz3 == 's'){
			if(x < n){
				x++;
			}
			h1 = true;
		}else if(zzz3 == 'A' || zzz3 == 'a'){
			if(y > 1){
				y--;
			}
			h1 = true;
		}else if(zzz3 == 'D' || zzz3 == 'd'){
			if(y < m){
				y++;
			}
			h1 = true;
		}else if(zzz3 == 'K' || zzz3 == 'k'){
			if(map[x][y] == 1){
				bool h2 = false; 
				for(int i = 1; i <= m1; i++){
					if(wu[i][0] == 0 && wu[i][1] == x && wu[i][2] == y){
						wu[i][0] = 1;
						h2 = true;
						break;
					}
				}
				if(!h2){
					block(2, n + 4);
					cout << "这个物品已经找过了……";
					Sleep(2500);
					block(2, n + 4);
					cout << "                      ";
				}else{
					wul--;
					block(2, n + 4);
					cout << "你成功找到了一个物品!";
					Sleep(2500);
					block(2, n + 4);
					cout << "                      ";
				}
			}else{
				cuo++;
				block(2, n + 4);
				cout << "你找错了!";
				Sleep(2500);
				block(2, n + 4);
				cout << "                    ";
			}
		}
		if(h1){
			if(map[x][y] == 2){
				block(y * 2 + 4, x + 2);
				color(12);
				cout << "¤";
				color(15);
				Sleep(1500);
				block(2, n + 4);
				cout << "你踩到炸弹了!";
				zha++;
				Sleep(1500);
				block(2, n + 4);
				cout << "                    ";
			}
			block(cy * 2 + 4, cx + 2);
			cout << "  ";
			cy = y;
			cx = x;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(map[i][j] == 2){
				block(j * 2 + 4, i + 2);
				color(12);
				cout << "¤";
			}else if(map[i][j] == 1){
				block(j * 2 + 4, i + 2);
				color(11);
				cout << "□";
			}
		}
	}
	color(15);
	if(h){
		block(2, n + 4);
		cout << "你获胜了!!!";
		Sleep(5000);
		cout << endl;
		system("pause");
	}else{
		block(2, n + 4);
		cout << "你失败了!!!";
		Sleep(5000);
		cout << endl;
		system("pause");
	}
}

void playy(){
	for(int i = 1; i <= m3; i++){
		x3[i] = (n + 1) / 2;
		y3[i] = (m + 1) / 2;
	}
	m344 = m3;
	memset(m44, 0, sizeof(m44));
	memset(m34, 0, sizeof(m34));
	memset(zha3, 0, sizeof(zha3));
	memset(cuo3, 0, sizeof(cuo3));
	if(n <= 10){
		if(m <= 10){
			system("mode con cols=28 lines=16");
		}else if(m <= 20){
			system("mode con cols=48 lines=16");
		}else if(m <= 30){
			system("mode con cols=68 lines=16");
		}else if(m <= 40){
			system("mode con cols=88 lines=16");
		}else{
			system("mode con cols=108 lines=16");
		}
	}else if(n <= 20){
		if(m <= 10){
			system("mode con cols=28 lines=26");
		}else if(m <= 20){
			system("mode con cols=48 lines=26");
		}else if(m <= 30){
			system("mode con cols=68 lines=26");
		}else if(m <= 40){
			system("mode con cols=88 lines=26");
		}else{
			system("mode con cols=108 lines=26");
		}
	}else{
		if(m <= 10){
			system("mode con cols=28 lines=36");
		}else if(m <= 20){
			system("mode con cols=48 lines=36");
		}else if(m <= 30){
			system("mode con cols=68 lines=36");
		}else if(m <= 40){
			system("mode con cols=88 lines=36");
		}else{
			system("mode con cols=108 lines=36");
		}
	}
	play2();
	system("cls");
	cout << "游戏开始!" << endl;
	Sleep(2500);
	system("cls");
	Sleep(500);
	color(15);
	for(int j = 1; j <= m; j++){
		block(j * 2 + 4, 2);
		cout << "—";
		block(j * 2 + 4, n + 3);
		cout << "—";
	}
	for(int i = 1; i <= n; i++){
		block(4, i + 2);
		cout << "| ";
		block(m * 2 + 5, i + 2);
		cout << " |";
	}
	block(4, 2);
	cout << "╭";
	block(m * 2 + 5, 2);
	cout << "╮";
	block(4, n + 3);
	cout << "╰";
	block(m * 2 + 5, n + 3);
	cout << "╯";
	if(m2 > 0){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				if(map[i][j] == 2){
					block(j * 2 + 4, i + 2);
					color(12);
					cout << "¤";
				}
			}
		}
		color(15);
		block(2, n + 4);
		cout << "请先记住炸弹的位置。";
		Sleep(1500);
		block(2, n + 4);
		cout << "                    ";
		block(2, n + 4);
		system("pause");
		block(2, n + 4);
		cout << "                    ";
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++){
				block(j * 2 + 4, i + 2);
				cout << "  ";
			}
		}
	}
	color(15);
	bool h = false;
	bool h3[6];
	memset(h3, false, sizeof(h3));
	for(int i = 1; i <= m3; i++){
		cx3[i] = x3[i];
		cy3[i] = y3[i];
	}
	while(true){
		if(wul == 0){
			h = true;
			break;
		}
		bool h4 = false;
		for(int i = 1; i <= m3; i++){
			if(!h3[i]){
				h4 = true;
				break;
			}
		}
		if(!h4){
			break;
		}
		block(2, 1);
		cout << "剩余物体数:" << wul;
		for(int i = 1; i <= m3; i++){
			if(!h3[i] && (zha3[i] >= 3 || cuo3[i] >= 3)){
				block(2, n + 4);
				color(m334[i]);
				cout << "玩家" << i << "失败了!";
				m34[i] = m344;
				m344--;
				h3[i] = true;
				Sleep(500);
				color(15);
				block(2, n + 4);
				cout << "                      ";
			}
			if(h3[i]){
				continue;
			}
			color(m334[i]);
			if(r1){
				block(y3[i] * 2 + 4, x3[i] + 2);
				int i2 = 1;
				while(wu[i2][0] != 0){
					i2++;
				}
				if(wu[i2][1] > x3[i]){
					if(wu[i2][2] > y3[i]){
						cout << "↘";
					}else if(wu[i2][2] == y3[i]){
						cout << "↓";
					}else{
						cout << "↙";
					}
				}else if(wu[i2][1] == x3[i]){
					if(wu[i2][2] > y3[i]){
						cout << "→";
					}else if(wu[i2][2] == y3[i]){
						cout << "㊣"; 
					}else{
						cout << "←";
					}
				}else{
					if(wu[i2][2] > y3[i]){
						cout << "↗";
					}else if(wu[i2][2] == y3[i]){
						cout << "↑";
					}else{
						cout << "↖";
					}
				}
			}else{
				block(y3[i] * 2 + 4, x3[i] + 2);
				int sum1 = 0;
				for(int j = 1; j <= m1; j++){
					if(wu[j][0] == 0){
						sum1 += (abs(x3[i] - wu[j][1]) + abs(y3[i] - wu[j][2]));
					}
				}
				double sum2 = 1.00 * sum1 / wul;
				if(sum2 <= 2.0){
					cout << "▇";
				}else if(sum2 <= 5.0){
					cout << "▅";
				}else if(sum2 <= 10.0){
					cout << "▃";
				}else{
					cout << "▁";
				}
			}
		}
		color(15);
		char zzz3 = getch();
		for(int i = 1; i <= m3; i++){
			if(h3[i]){
				continue;
			}
			bool h1 = false;
			if(zzz3 == m33[i][1]){
				if(x3[i] > 1){
					x3[i]--;
				}
				h1 = true; 
			}else if(zzz3 == m33[i][2]){
				if(x3[i] < n){
					x3[i]++;
				}
				h1 = true;
			}else if(zzz3 == m33[i][3]){
				if(y3[i] > 1){
					y3[i]--;
				}
				h1 = true;
			}else if(zzz3 == m33[i][4]){
				if(y3[i] < m){
					y3[i]++;
				}
				h1 = true;
			}else if(zzz3 == m33[i][5]){
				if(map[x3[i]][y3[i]] == 1){
					bool h2 = false; 
					for(int j = 1; j <= m1; j++){
						if(wu[j][0] == 0 && wu[j][1] == x3[i] && wu[j][2] == y3[i]){
							wu[j][0] = 1;
							h2 = true;
							break;
						}
					}
					if(!h2){
						block(2, n + 4);
						color(m334[i]);
						cout << "这个物品已经找过了……";
						Sleep(500);
						block(2, n + 4);
						color(15);
						cout << "                      ";
					}else{
						wul--;
						block(2, n + 4);
						color(m334[i]);
						cout << "你成功找到了一个物品!";
						m44[i]++;
						Sleep(500);
						color(15);
						block(2, n + 4);
						cout << "                      ";
					}
				}else{
					cuo3[i]++;
					block(2, n + 4);
					color(m334[i]);
					cout << "你找错了!";
					Sleep(500);
					color(15);
					block(2, n + 4);
					cout << "                    ";
				}
			}
			if(h1){
				if(map[x3[i]][y3[i]] == 2){
					block(y3[i] * 2 + 4, x3[i] + 2);
					color(12);
					cout << "¤";
					color(m334[i]);
					Sleep(500);
					block(2, n + 4);
					cout << "你踩到炸弹了!";
					zha3[i]++;
					Sleep(500);
					block(2, n + 4);
					color(15);
					cout << "                    ";
				}
				block(cy3[i] * 2 + 4, cx3[i] + 2);
				cout << "  ";
				cy3[i] = y3[i];
				cx3[i] = x3[i];
			}
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(map[i][j] == 2){
				block(j * 2 + 4, i + 2);
				color(12);
				cout << "¤";
			}else if(map[i][j] == 1){
				block(j * 2 + 4, i + 2);
				color(11);
				cout << "□";
			}
		}
	}
	color(15);
	if(h){
		block(2, n + 4);
		cout << "你们获胜了!!!";
		while(m344 > 0){
			int an2 = 20, an3 = 5, an4 = 5, an5 = 0;
			for(int i = 1; i <= m3; i++){
				if(!h3[i]){
					if(m44[i] < an2){
						an2 = m34[i];
						an3 = zha3[i];
						an4 = cuo3[i];
						an5 = i;
					}else if(m44[i] == an2){
						if(cuo3[i] > an3){
							an2 = m34[i];
							an3 = zha3[i];
							an4 = cuo3[i];
							an5 = i;
						}else if(cuo3[i] == an4){
							if(zha3[i] < an3){
								an2 = m34[i];
								an3 = zha3[i];
								an4 = cuo3[i];
								an5 = i;
							}
						}
					}
				}
			}
			m34[an5] = m344;
			m344--;
			h3[an5] = true;
		}
		Sleep(5000);
		cout << endl;
		system("pause");
	}else{
		block(2, n + 4);
		cout << "你们失败了!!!";
		Sleep(5000);
		cout << endl;
		system("pause");
	}
	system("cls");
	cout << "游戏记录:" << endl;
	Sleep(1000);
	for(int i = 1; i <= m3; i++){
		system("cls");
		cout << "  ";
		color(m334[i]);
		cout << "玩家" << i;
		Sleep(1000);
		color(15);
		cout << endl << "    第" << m34[i] << "名" << endl;
		Sleep(500);
		cout << "    碰到了" << zha3[i] << "个炸弹" << endl;
		Sleep(500);
		cout << "    找错了" << cuo3[i] << "次物品" << endl;
		Sleep(500);
		cout << "    找到了" << m44[i] << "个物品" << endl;
		Sleep(500);
		system("pause");
	}
}

int main( ){
	system("mode con cols=40 lines=10");
	system("title 找东西游戏——by蒟蒻XTW");
	color(15);
	Sleep(1000);
	cout << "欢迎来到蒟蒻XTW的找东西游戏!" << endl;
	Sleep(1000);
	cout << "即将进入主界面……" << endl;
	Sleep(1500);
	HideCursor();
	p0:system("cls");
	system("mode con cols=20 lines=5");
	cout << "主界面:" << endl;
	Sleep(500);
	cout << "    1.普通游戏" << endl;
	Sleep(50);
	cout << "    2.自定义游戏" << endl;
	Sleep(50);
	cout << "    0.退出" << endl;
	Sleep(50);
	p_1:char zzz0 = getch();
	if(zzz0 == '1'){
		p_2:system("cls");
		system("mode con cols=20 lines=8");
		cout << "普通游戏:" << endl;
		Sleep(500);
		cout << "    1.开始游戏!" << endl;
		Sleep(50);
		if(r1){
			cout << "    2.模式:箭头" << endl;
			Sleep(50);
		}else{
			cout << "    2.模式:普通" << endl;
			Sleep(50);
		}
		if(r2){
			cout << "    3.模式:多物品" << endl;
			Sleep(50);
		}else{
			cout << "    3.模式:单物品" << endl;
			Sleep(50);
		}
		if(r3){
			cout << "    4.模式:有炸弹" << endl;
			Sleep(50);
		}else{
			cout << "    4.模式:无炸弹" << endl;
			Sleep(50);
		}
		cout << "    5.查看规则" << endl;
		Sleep(50);
		cout << "    0.退出" << endl;
		Sleep(50);
		p1:char zzz1 = getch();
		if(zzz1 == '0'){
			goto p0;
		}else if(zzz1 == '1'){
			play();
			goto p_2;
		}else if(zzz1 == '2'){
			r1 = !r1;
			output0_1();
			goto p1;
		}else if(zzz1 == '3'){
			r2 = !r2;
			output0_1();
			goto p1;
		}else if(zzz1 == '4'){
			r3 = !r3;
			output0_1();
			goto p1; 
		}else if(zzz1 == '5'){
			system("cls");
			system("mode con cols=80 lines=10");
			cout << "规则:" << endl;
			Sleep(500);
			cout << "    (1) 用 w a s d 来移动,W A S D 也可以。" << endl;
			Sleep(500);
			cout << "    (2) 箭头模式中,箭头指向物品的位置。" << endl;
			Sleep(500);
			cout << "    (3) 其它模式中,方块的大小表示距离物品的远近,方块越大距离越近。" << endl;
			Sleep(500);
			cout << "    (3).2 距离的算法:算出每个物品的曼哈顿距离,再求平均。" << endl;
			Sleep(500);
			cout << "    (3).3 距离的表示:S≤2为▇,2<S≤5为▅,5<S≤10为▃,S>10为▁" << endl;
			Sleep(500);
			cout << "    (4) 炸弹模式中,你要记住炸弹的位置,碰到3个则输,一个炸弹可以重复碰" << endl;
			Sleep(500);
			cout << "    (5) 如果你确定自己所在的位置有物品,按下 k。每局有3次错误机会。" << endl;
			Sleep(500);
			system("pause");
			goto p_2;
		}else{
			goto p1;
		}
	}else if(zzz0 == '2'){
		p_10:system("cls");
		system("mode con cols=25 lines=15");
		color(15);
		cout << "自定义游戏:" << endl;
		Sleep(500);
		cout << "    1.开始游戏!" << endl;
		Sleep(50);
		if(r1){
			cout << "    2.模式:箭头" << endl;
			Sleep(50);
		}else{
			cout << "    2.模式:普通" << endl;
			Sleep(50);
		}
		Sleep(50);
		cout << "    3.面积:" << n << "*" << m << endl;
		Sleep(50);
		cout << "    4.物品数:" << m1 << endl;
		Sleep(50);
		cout << "    5.炸弹数:" << m2 << endl;
		Sleep(50);
		cout << "    6.玩家操作:" << endl;
		Sleep(50);
		for(int i = 1; i <= m3; i++){
		cout << "      ";
		color(m334[i]);
		cout << "玩家" << i << ":";
		color(15);
		cout << m33[i][1] << " " << m33[i][2] << " " << m33[i][3] << " " << m33[i][4] << " " << m33[i][5] << endl;
		Sleep(50);
		}
		cout << "    0.退出" << endl;
		Sleep(50);
		p_3:char zzz_1 = getch();
		if(zzz_1 == '1'){
			playy();
			goto p_10;
		}else if(zzz_1 == '2'){
			r1 = !r1;
			output0_2();
			goto p_3;
		}else if(zzz_1 == '3'){
			cout << endl << "  请输入行(8~30):";
			int zzz_2;
			p_5:cin >> zzz_2;
			if(zzz_2 > 30 || zzz_2 < 8){
				goto p_5;
			}
			n = zzz_2;
			cout << endl << "  请输入列(8~50):";
			zzz_2;
			p_6:cin >> zzz_2;
			if(zzz_2 > 50 || zzz_2 < 8){
				goto p_6;
			}
			m = zzz_2;
			if(m2 > n * m - 20){
				m2 = n * m - 20;
			}
			output0_2();
			goto p_3;
		}else if(zzz_1 == '4'){
			cout << endl << "  请输入物品数(1~10):";
			int zzz_2;
			p_4:cin >> zzz_2;
			if(zzz_2 > 10 || zzz_2 < 1){
				goto p_4;
			}
			m1 = zzz_2;
			output0_2();
			goto p_3;
		}else if(zzz_1 == '5'){
			cout << endl << "  请输入炸弹(0~" << n * m - 20 << ")";
			int zzz_2;
			p_7:cin >> zzz_2;
			if(zzz_2 > n * m - 20 || zzz_2 < 0){
				goto p_7;
			}
			m2 = zzz_2;
			output0_2();
			goto p_3;
		}else if(zzz_1 == '6'){
			system("cls");
			cout << endl << "  请输入玩家数(1~5):";
			int zzz_2;
			p_8:cin >> zzz_2;
			if(zzz_2 > 5 || zzz_2 < 1){
				goto p_8;
			}
			m3 = zzz_2;
			for(int i = 1; i <= m3; i++){
				system("cls");
				color(15);
				cout << "    获取玩家" << i << "的操作中…";
				Sleep(50);
				cout << endl << "      上:";
				m33[i][1] = getch();
				cout << m33[i][1];
				cout << endl << "      下:";
				m33[i][2] = getch();
				cout << m33[i][2];
				cout << endl << "      左:";
				m33[i][3] = getch();
				cout << m33[i][3];
				cout << endl << "      右:";
				m33[i][4] = getch();
				cout << m33[i][4];
				cout << endl << "      确定:";
				m33[i][5] = getch();
				cout << m33[i][5];
				cout << endl << "      颜色:" << endl;
				cout << "        1.确定" << endl;
				cout << "        2.切换颜色" << endl;
				int zzz_5 = 15;
				p_9:block(10, 10);
				color(zzz_5);
				cout << "■";
				char zzz_4 = getch();
				if(zzz_4 == '1'){
					m334[i] = zzz_5;
				}else if(zzz_4 == '2'){
					zzz_5--;
					if(zzz_5 < 0){
						zzz_5 = 15;
					}
					goto p_9;
				}else{
					goto p_9;
				}
			}
			goto p_10;
		}else if(zzz_1 == '0'){
			goto p0;
		}else{
			goto p_3;
		}
	}else if(zzz0 == '0'){
		return 0;
	}else{
		goto p_1;
	}
	return 0;
}
原文
存档评论1 条抓取于