目录
- 开头
- 程序
- 程序的流程图
- 程序游玩的效果
- 下一篇博客要说的东西
开头
大家好xff0c;我叫这是我58。
程序
y">#yword">include <iostream>
yword">using yword">namespace std;
yword">void printmaze(yword">char strmaze[5][5][5]) {cout << "-----@" << endl;yword">int i = 0;yword">int ia = 0;yword">int ib = 0;yword">for (; i < 5; i++) {yword">for (ia = 0; ia < 5; ia++) {yword">for (ib = 0; ib < 5; ib++) {cout << "\033[" << ('G' == strmaze[i][ia][ib] ? "32;1" : "0") << "m" << strmaze[i][ia][ib] << "\033[0m";}cout << "|" << endl;}cout << "-----@" << endl;}
}
yword">int main() {yword">char strmaze[5][5][5] = {'P','*',' ','*','*','*',' ',' ',' ','*',' ',' ','*',' ',' ',' ','*','*','*',' ',' ',' ','*',' ',' ',' ',' ','*',' ',' ',' ','*',' ','*',' ','*','*','*','*','*',' ',' ','*',' ',' ',' ',' ','*',' ',' ','*',' ',' ','*',' ','*',' ','*',' ',' ',' ','*',' ','*','*',' ',' ','*',' ',' ',' ',' ','*',' ',' ','*','*',' ',' ',' ',' ',' ','*','*',' ',' ',' ','*',' ','*',' ',' ','*',' ',' ',' ',' ','*','*',' ','*','*',' ',' ',' ','*',' ',' ',' ',' ',' ','*','*',' ','*',' ',' ','*','*','*',' ','*',' ',' ','G',};yword">char* cp = &strmaze[0][0][0];yword">char ch = 0;cout << "欢迎你来玩这个3D迷宫xff0c;在这个迷宫中xff0c;“P”是你xff0c;“*”是墙xff0c;空格是你可以走的地方xff0c;而\033[32;1m“G”\033[0m是\033[32;1m终点\033[0mxff0c;走到这就能让你胜利了xff0c;并且xff0c;按“w”能使你往上移xff0c;按“a”能使你往左移xff0c;按“s”能使你往下移xff0c;按“d”能使你往右移xff0c;按“q”能使你上一层xff0c;按“e”能使你下一层。这就是这迷宫的规则xff0c;你听明白了吗?" << endl << endl;system("pause");system("cls");yword">while ('G' == strmaze[4][4][4]) {yword">int ix = (cp - &strmaze[0][0][0]) / 25;yword">int iy = (cp - &strmaze[0][0][0]) / 5 % 5;yword">int iz = (cp - &strmaze[0][0][0]) % 5;printmaze(strmaze);cin >> ch;rewind(stdin);*cp = ' ';yword">switch (ch) {yword">case 'w':iy && '*' != *(cp - 5) && (cp -= 5);yword">break;yword">case 'a':iz && '*' != *(cp - 1) && (cp--);yword">break;yword">case 's':4 != iy && '*' != *(cp + 5) && (cp += 5);yword">break;yword">case 'd':4 != iz && '*' != *(cp + 1) && (cp++);yword">break;yword">case 'q':ix && '*' != *(cp - 25) && (cp -= 25);yword">break;yword">case 'e':4 != ix && '*' != *(cp + 25) && (cp += 25);yword">break;yword">default:yword">break;}*cp = 'P';system("cls");}system("color 0A");cout << "恭喜你xff0c;你赢了" << endl;yword">return 0;
}
程序的流程图
程序游玩的效果
下一篇博客要说的东西
C++掉血迷宫