wewrhdferftr4e

最近看到好多大佬都在编小游戏了 本蒟蒻也编了一个

#include <iostream>

#include <conio.h>



const int GAME_WIDTH = 20;

const int GAME_HEIGHT = 10;

const char PLAYER_CHAR = 'P';

const char OBSTACLE_CHAR = '#';

const char EMPTY_CHAR = ' ';



void drawGame(char gameBoard[GAME_HEIGHT][GAME_WIDTH], int playerX) {

    system("cls");  // 清空控制台屏幕



    for (int i = 0; i < GAME_HEIGHT; i++) {

        for (int j = 0; j < GAME_WIDTH; j++) {

            if (j == playerX) {

                std::cout << PLAYER_CHAR;

            } else {

                std::cout << gameBoard[i][j];

            }

        }

        std::cout << std::endl;

    }

}



int main() {

    char gameBoard[GAME_HEIGHT][GAME_WIDTH];

    int playerX = GAME_WIDTH / 2;

    bool gameOver = false;



    // 初始化游戏板

    for (int i = 0; i < GAME_HEIGHT; i++) {

        for (int j = 0; j < GAME_WIDTH; j++) {

            gameBoard[i][j] = EMPTY_CHAR;

        }

    }



    while (!gameOver) {

        // 绘制游戏界面

        drawGame(gameBoard, playerX);



        // 处理用户输入

        if (_kbhit()) {

            char input = _getch();

            if (input == 'a' && playerX > 0) {

                playerX--;

            } else if (input == 'd' && playerX < GAME_WIDTH - 1) {

                playerX++;

            } else if (input == 'q') {

                gameOver = true;

            }

        }



        // 更新游戏状态



        // 暂停一段时间,控制游戏速度

        // 这里使用了简单的延时函数,实际开发中可能需要更精确的时间控制方式

        // 例如使用std::chrono库

        Sleep(100);

    }



    std::cout << "游戏结束!" << std::endl;



    return 0;

}
5 个赞

标题跟风一下 最近流行标题乱打(

1 个赞
#include<bits/stdc++.h>
#include<windows.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
using namespace std;
int size[24]={5,5,5,7,9,5,5,5,7,9,5,5,5,7,9,5,5,5,7,9,5,5,5,7},mirror[24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,1,3,0,0,0,3},dx[5]={0,0,0,0,1},dy[5]={1,-1,0,0,0},dz[5]={0,0,1,-1,0};
bool gravity[24]={0,0,0,0,0,1,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,1,1,1};
char loop[4][26],gaming[9][9][9],maze[24][9][9][10]={{{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},{
			"#####",
			"#...#",
			"###.#",
			"#E..#",
			"#####"
		},{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},{{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},{
			"#####",
			"#...#",
			"#####",
			"#E..#",
			"#####"
		},
		{
			"#####",
			"###.#",
			"#####",
			"###.#",
			"#####"
		},
		{
			"#####",
			"###.#",
			"###.#",
			"###.#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#####",
			"#E..#",
			"#####"
		},
		{
			"#####",
			"#.#.#",
			"#####",
			"###.#",
			"#####"
		},
		{
			"#####",
			"#.#.#",
			"#.###",
			"#...#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#...#.#",
			"#####.#",
			"#.#.#.#",
			"#.#.#.#",
			"#.....#",
			"#######"
		},
		{
			"#######",
			"#.#.#.#",
			"#######",
			"###.###",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#.#...#",
			"#######",
			"#...#.#",
			"#####.#",
			"#.....#",
			"#######"
		},
		{
			"#######",
			"#.###.#",
			"#######",
			"#.###.#",
			"#######",
			"#.#####",
			"#######"
		},
		{
			"#######",
			"#...#.#",
			"###.###",
			"#.#...#",
			"###.###",
			"#E#...#",
			"#######"
		},
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		}
	},
	{
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		},
		{
			"#########",
			"#...#...#",
			"#####.###",
			"#...#.#.#",
			"#.#####.#",
			"#.#...#.#",
			"#.#####.#",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.#.#####",
			"#########",
			"#####.###",
			"#########",
			"###.#.###",
			"#########",
			"###.#####",
			"#########"
		},
		{
			"#########",
			"#.#.....#",
			"#######.#",
			"#...#.#.#",
			"#.#.###.#",
			"#.#.#...#",
			"#.#####.#",
			"#.#.#...#",
			"#########"
		},
		{
			"#########",
			"#.#####.#",
			"#########",
			"#####.###",
			"#########",
			"###.#####",
			"#########",
			"###.#.###",
			"#########"
		},
		{
			"#########",
			"#.#...#.#",
			"#.###.###",
			"#.#.#...#",
			"#.#######",
			"#.#.#...#",
			"#.###.###",
			"#...#.#.#",
			"#########"
		},
		{
			"#########",
			"#.#.###.#",
			"#########",
			"###.###.#",
			"#########",
			"###.###.#",
			"#########",
			"###.###.#",
			"#########"
		},
		{
			"#########",
			"#.#.#...#",
			"#.#.#.###",
			"#...#.#.#",
			"#########",
			"#...#...#",
			"#.#######",
			"#E#.....#",
			"#########"
		},
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####" 
		},
		{
			"#####",
			"#...#",
			"###.#",
			"#E..#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#..##",
			"##..#",
			"#...#",
			"#####"
		},
		{
			"#####",
			"##E.#",
			"###.#",
			"#.###",
			"#####"
		},
		{
			"#####",
			"##..#",
			"##.##",
			"#..##",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"###.#",
			"#...#",
			"#####"
		},
		{
			"#####",
			"##..#",
			"#E###",
			"##.##",
			"#####"
		},
		{
			"#####",
			"###.#",
			"#...#",
			"###.#",
			"#####",
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#.....#",
			"##.#..#",
			"#..#..#",
			"##.#.##",
			"##.#.##",
			"#######"
		},
		{
			"#######",
			"#...#.#",
			"#######",
			"#.#...#",
			"##.#.##",
			"####.##",
			"#######"
		},
		{
			"#######",
			"#.#.#.#",
			"#.#####",
			"#...#.#",
			"##.####",
			"####.##",
			"#######"
		},
		{
			"#######",
			"#.#...#",
			"###..##",
			"##.#..#",
			"####.##",
			"#.....#",
			"#######"
		},
		{
			"#######",
			"#.##..#",
			"#....##",
			"##..#E#",
			"#######",
			"#.#.#.#",
			"#######"
		},
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		}
	},
	{
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		},
		{
			"#########",
			"#.....#.#",
			"#####.#.#",
			"#####.#.#",
			"#####.#.#",
			"#......E#",
			"#####.###",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.#.###.#",
			"#########",
			"#########",
			"#########",
			"#.#######",
			"#########",
			"#.#######",
			"#########"
		},
		{
			"#########",
			"#.#...#.#",
			"#####.###",
			"#####...#",
			"#######.#",
			"#.###...#",
			"#######.#",
			"#.#####.#",
			"#########"
		},
		{
			"#########",
			"#.#####.#",
			"#########",
			"#####.###",
			"#####.###",
			"#.###.#.#",
			"#######.#",
			"#.#######",
			"#########"
		},
		{
			"#########",
			"#..####.#",
			"##..#####",
			"###...###",
			"#######.#",
			"#...###.#",
			"###.#####",
			"#.#.#####",
			"#########"
		},
		{
			"#########",
			"#.#####.#",
			"#########",
			"#####.#.#",
			"#######.#",
			"#.#######",
			"#########",
			"#.#.#####",
			"#########"
		},
		{
			"#########",
			"#.##....#",
			"#.#..####",
			"#...#...#",
			"#..######",
			"#.#######",
			"#########",
			"#...#####",
			"#########"
		},
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#.###",
			"#.###",
			"#####",
			"#####"
		},
		{
			"#####",
			"###.#",
			"#.*.#",
			"##..#",
			"#####"
		},
		{
			"#####",
			"#####",
			"###E#",
			"#####",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#..##",
			"#####",
			"#...#",
			"#####"
		},
		{
			"#####",
			"#.*##",
			"#.###",
			"#.#.#",
			"#####"
		},
		{
			"#####",
			"##.E#",
			"##.##",
			"#...#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"##..#",
			"#..!#",
			"#####"
		},
		{
			"#####",
			"#.*.#",
			"###!#",
			"#.!E#",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#!#.#",
			"#.!.#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#.#..##",
			"#..!..#",
			"#######",
			"#######",
			"#....E#",
			"#######"
		},
		{
			"#######",
			"##..###",
			"#.*.#.#",
			"###.###",
			"###.###",
			"#.#####",
			"#######"
		},
		{
			"#######",
			"#######",
			"###...#",
			"#.!####",
			"#.#*.##",
			"#.#####",
			"#######"
		},
		{
			"#######",
			"#######",
			"#######",
			"#..####",
			"##...##",
			"##..###",
			"#######"
		},
		{
			"#######",
			"#######",
			"#######",
			"##.####",
			"##.####",
			"#######",
			"#######" 
		},
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		}
	},
	{
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		},
		{
			"#########",
			"#.......#",
			"#######.#",
			"#########",
			"#########",
			"#########",
			"#########",
			"#.....###",
			"#########"
		},
		{
			"#########",
			"#..######",
			"#.#####.#",
			"#..####.#",
			"#########",
			"###...###",
			"###.#####",
			"#.###*###",
			"#########"
		},
		{
			"#########",
			"#..######",
			"#!#######",
			"#.*#..#.#",
			"#.#####.#",
			"#.###*###",
			"###.#####",
			"#.#.#.###",
			"#########"
		},
		{
			"#########",
			"#..######",
			"#!#######",
			"#.....###",
			"#######.#",
			"#.###.#.#",
			"#########",
			"#.#.#.###",
			"#########"
		},
		{
			"#########",
			"#..######",
			"#!#######",
			"#.....###",
			"###!#.###",
			"#.....#.#",
			"#####.#.#",
			"#.#.#.###",
			"#########"
		},
		{
			"#########",
			"#..######",
			"#!#######",
			"##...####",
			"#########",
			"#......##",
			"#!!!!##.#",
			"#.#.#.#.#",
			"#########"
		},
		{
			"#########",
			"#..######",
			"#.#######",
			"#.#######",
			"#E#######",
			"#.......#",
			"#######.#",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#####",
			"#E..#",
			"#####"
		},
		{
			"#####",
			"###.#",
			"#####",
			"###.#",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#.###",
			"#...#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#####",
			"#E..#",
			"#####"
		},
		{
			"#####",
			"###.#",
			"#####",
			"###.#",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#.###",
			"#...#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#####",
			"#E..#",
			"#####"
		},
		{
			"#####",
			"###.#",
			"#####",
			"###.#",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#.###",
			"#...#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#.....#",
			"##!####",
			"#.....#",
			"####!.#",
			"#.....#",
			"##!#!##"
		},
		{
			"#######",
			"#.....#",
			"##!#!##",
			"#.....#",
			"##!#!##",
			"#.....#",
			"##!#!##"
		},
		{
			"#######",
			"#.....#",
			"##!.!##",
			"#.....#",
			"##!#!##",
			"#.....#",
			"##!####"
		},
		{
			"#######",
			"#.....#",
			"##!!!##",
			"#.....#",
			"##!#!##",
			"#.....#",
			"##!!!!#"
		},
		{
			"#######",
			"#.....#",
			"#######",
			"#.....#",
			"#.!####",
			"#....E#",
			"#######"
		},
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		}
	},
	{
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		},
		{
			"#########",
			"#.#####.#",
			"######..#",
			"#...#..##",
			"####..###",
			"#....####",
			"#########",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.#####.#",
			"#########",
			"#.#.#####",
			"#########",
			"#.#.#####",
			"#########",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.*.*...#",
			"###.#####",
			"#.*.###.#",
			"###.###E#",
			"#.......#",
			"##.######",
			"#.#.....#",
			"#########"
		},
		{
			"#########",
			"#.###.###",
			"#########",
			"#.#.###.#",
			"#########",
			"#.#.#.###",
			"#########",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.....###",
			"#########",
			"#.#.###.#",
			"#.#######",
			"#.#...###",
			"#########",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.#.#.###",
			"#########",
			"###.###.#",
			"#########",
			"#########",
			"#########",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#.#.#.###",
			"#.#.#!###",
			"#.#.....#",
			"#.#.#####",
			"#.#.#####",
			"#.#######",
			"#.......#",
			"#########"
		},
		{
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########",
			"#########"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"###.#",
			"#E#O#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#O#O#",
			"#####"
		},
		{
			"#####",
			"#...#",
			"#.#.#",
			"#O#O#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#..##",
			"#####",
			"#E#O#",
			"#####"
		},
		{
			"#####",
			"##*##",
			"#####",
			"#O#O#",
			"#####"
		},
		{
			"#####",
			"##..#",
			"##..#",
			"#OOO#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		},
		{
			"#####",
			"#...#",
			"##OO#",
			"##OO#",
			"#####"
		},
		{
			"#####",
			"#.###",
			"#.#*#",
			"#.###",
			"#####"
		},
		{
			"#####",
			"#E..#",
			"##..#",
			"##..#",
			"#####"
		},
		{
			"#####",
			"#####",
			"#####",
			"#####",
			"#####"
		}
	},
	{
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#..E#O#",
			"##.####",
			"#..##O#",
			"##.####",
			"##.####",
			"#######"
		},
		{
			"#######",
			"##..#O#",
			"#.#.###",
			"#.#.#O#",
			"#######",
			"##....#",
			"#######"
		},
		{
			"#######",
			"#...*O#",
			"#.#.###",
			"###.#O#",
			"###OOO#",
			"###*###",
			"#######"
		},
		{
			"#######",
			"#.###O#",
			"#######",
			"#####O#",
			"#######",
			"###.###",
			"#######"
		},
		{
			"#######",
			"#..#OO#",
			"##OOO##",
			"#######",
			"#######",
			"#######",
			"#######"
		},
		{
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######",
			"#######"
		}
	}
};
struct water{
	int x,y,z;
};
queue<water>que;
char press()
{
	for(char i=65;i<=90;i++)
		if(KEY_DOWN(i))
			return i;
	return '\0';
}
int main()
{
	char ch;
	int x,y,z,game,top,eye;
	bool box;
	water t,r;
	for(int i=0;i<=3;i++)
		for(int j=0;j<=25;j++)
			loop[i][j]=char(j+65);
	swap(loop[1][0],loop[1][3]);
	swap(loop[2][18],loop[2][22]);
	swap(loop[3][2],loop[3][17]);
	while(1)
	{
		system("cls");
		cout<<"菜单"<<endl; 
		cout<<"按Z进入第一章:基础"<<endl;
		cout<<"按X进入第二章:重力"<<endl;
		cout<<"按C进入第三章:机关"<<endl;
		cout<<"按V进入第四章:镜像"<<endl;
		cout<<"按B进入第五章:水"<<endl;
		ch='\0';
		while(ch!='Z'&&ch!='X'&&ch!='C'&&ch!='V'&&ch!='B')
			ch=press();
		if(ch=='Z')
		{
			game=0;
			top=5;
		}
		else if(ch=='X')
		{
			game=5;
			top=10;
		}
		else if(ch=='C')
		{
			game=10;
			top=15;
		}
		else if(ch=='V')
		{
			game=15;
			top=20;
		}
		else
		{
			game=20;
			top=24;
		}

推荐,走迷宫,高级版
1-1343

1 个赞
while(game<top)
		{
			x=y=z=eye=1;
			for(int i=0;i<size[game];i++)
				for(int j=0;j<size[game];j++)
					for(int k=0;k<size[game];k++)
						gaming[i][j][k]=maze[game][i][j][k];
			while(1)
			{
				if((!gravity[game]||gaming[z][x+1][y]=='#'||gaming[z][x+1][y]=='*'||gaming[z][x+1][y]=='O')&&gaming[z][x][y]=='E')
					break;
				if(gaming[z][x][y]=='!')
				{
					x=y=z=eye=1;
					for(int i=0;i<size[game];i++)
						for(int j=0;j<size[game];j++)
							for(int k=0;k<size[game];k++)
								gaming[i][j][k]=maze[game][i][j][k];
				}
				system("cls");
				cout<<"关卡"<<game+1<<endl;
				cout<<"重力:";
				if(gravity[game])
					cout<<"开启"<<endl;
				else
					cout<<"关闭"<<endl;
				cout<<"镜像:";
				if(mirror[game]==0)
					cout<<"无"<<endl;
				if(mirror[game]==1)
					cout<<"左右"<<endl;
				if(mirror[game]==2)
					cout<<"上下"<<endl;
				if(mirror[game]==3)
					cout<<"特殊"<<endl;
				if(game==0)
					cout<<"WASD移动,到达终点E即可通关。"<<endl;
				if(game==1)
					cout<<"按C切换视角。"<<endl;
				if(game==2)
					cout<<"迷宫里会有岔路,这是很正常的事。"<<endl;
				if(game==3)
					cout<<"来一点难的迷宫。"<<endl;
				if(game==4)
					cout<<"建议空间想象力不够丰富的不要玩。"<<endl;
				if(game==5)
					cout<<"本章拥有重力,所以W键和S键就废了。"<<endl;
				if(game==6)
					cout<<"你获得了爬楼梯的技能。"<<endl;
				if(game==7)
					cout<<"按R重开。"<<endl;
				if(game==10)
					cout<<"*是箱子,你可以推箱子。"<<endl;
				if(game==11)
					cout<<"箱子也能拥有重力。"<<endl;
				if(game==12)
					cout<<"岩浆可以毁灭你和箱子,小心岩浆!"<<endl;
				if(game==20)
					cout<<"你可以在水里游泳。"<<endl;
				if(game==21)
					cout<<"箱子可以悬浮在水中。"<<endl;
				if(game==22)
					cout<<"水会流动。"<<endl;
				if(eye==1)
				{
					cout<<"视角:正视角"<<endl;
					if(gravity[game])
					{
						while(1)
						{
							box=false;
							for(int i=0;i<size[game];i++)
								for(int j=size[game]-1;j>=0;j--)
									for(int k=0;k<size[game];k++)
										if(gaming[i][j][k]=='*'&&(gaming[i][j+1][k]=='.'||gaming[i][j+1][k]=='!')&&!(i==z&&j+1==x&&k==y))
											box=true;
							if(!box)
								break;
							for(int i=0;i<size[game];i++)
							{
								for(int j=0;j<size[game];j++)
									if(i==x&&j==y)
										cout<<"@";
									else
										cout<<gaming[z][i][j];
								cout<<endl;
							}
							for(int i=0;i<size[game];i++)
								for(int j=size[game]-1;j>=0;j--)
									for(int k=0;k<size[game];k++)
										if(gaming[i][j][k]=='*'&&(gaming[i][j+1][k]=='.'||gaming[i][j+1][k]=='!')&&!(i==z&&j+1==x&&k==y))
										{
											gaming[i][j][k]='.';
											if(gaming[i][j+1][k]!='!')
												gaming[i][j+1][k]='*';
										}
							Sleep(200);
							system("cls");
							cout<<"关卡"<<game+1<<endl;
							cout<<"重力:";
							if(gravity[game])
								cout<<"开启"<<endl;
							else
								cout<<"关闭"<<endl;
							cout<<"镜像:";
							if(mirror[game]==0)
								cout<<"无"<<endl;
							if(mirror[game]==1)
								cout<<"左右"<<endl;
							if(mirror[game]==2)
								cout<<"上下"<<endl;
							if(mirror[game]==3)
								cout<<"特殊"<<endl;
							if(game==5)
								cout<<"本章拥有重力,所以W键和S键就废了。"<<endl;
							if(game==6)
								cout<<"你获得了爬楼梯的技能。"<<endl;
							if(game==7)
								cout<<"按R重开。"<<endl;
							if(game==11)
								cout<<"箱子也能拥有重力。"<<endl;
							if(game==12)
								cout<<"岩浆可以毁灭你和箱子,小心岩浆!"<<endl;
							if(game==20)
								cout<<"你可以在水里游泳。"<<endl;
							if(game==21)
								cout<<"箱子可以悬浮在水中。"<<endl;
							if(game==22)
								cout<<"水会流动。"<<endl;
							cout<<"视角:正视角"<<endl;
						}
						while(gaming[z][x+1][y]!='#'&&gaming[z][x+1][y]!='*'&&gaming[z][x+1][y]!='O')
						{
							for(int i=0;i<size[game];i++)
							{
								for(int j=0;j<size[game];j++)
									if(i==x&&j==y)
										cout<<"@";
									else
										cout<<gaming[z][i][j];
								cout<<endl;
							}
							x++;
							Sleep(200);
							if((gaming[z][x+1][y]=='#'||gaming[z][x+1][y]=='*'||gaming[z][x+1][y]=='O')&&gaming[z][x][y]=='E')
								break;
							if(gaming[z][x][y]=='!')
							{
								x=y=z=eye=1;
								for(int i=0;i<size[game];i++)
									for(int j=0;j<size[game];j++)
										for(int k=0;k<size[game];k++)
											gaming[i][j][k]=maze[game][i][j][k];
							}
							system("cls");
							cout<<"关卡"<<game+1<<endl;
							cout<<"重力:";
							if(gravity[game])
								cout<<"开启"<<endl;
							else
								cout<<"关闭"<<endl;
							cout<<"镜像:";
							if(mirror[game]==0)
								cout<<"无"<<endl;
							if(mirror[game]==1)
								cout<<"左右"<<endl;
							if(mirror[game]==2)
								cout<<"上下"<<endl;
							if(mirror[game]==3)
								cout<<"特殊"<<endl;
							if(game==5)
								cout<<"本章拥有重力,所以W键和S键就废了。"<<endl;
							if(game==6)
								cout<<"你获得了爬楼梯的技能。"<<endl;
							if(game==7)
								cout<<"按R重开。"<<endl;
							if(game==11)
								cout<<"箱子也能拥有重力。"<<endl;
							if(game==12)
								cout<<"岩浆可以毁灭你和箱子,小心岩浆!"<<endl;
							if(game==20)
								cout<<"你可以在水里游泳。"<<endl;
							if(game==21)
								cout<<"箱子可以悬浮在水中。"<<endl;
							if(game==22)
								cout<<"水会流动。"<<endl;
							cout<<"视角:正视角"<<endl;
						}
					}
					if(gaming[z][x][y]=='E')
						break;
					for(int i=0;i<game[size];i++)
						for(int j=0;j<game[size];j++)
							for(int k=0;k<game[size];k++)
								if(gaming[i][j][k]=='O')
								{
									t.x=j;
									t.y=k;
									t.z=i;
									que.push(t);
								}
					while(!que.empty())
					{
						t=que.front();
						que.pop();
						for(int i=0;i<=4;i++)
						{
							r.x=t.x+dx[i];
							r.y=t.y+dy[i];
							r.z=t.z+dz[i];
							if(gaming[r.z][r.x][r.y]=='.')
							{
								gaming[r.z][r.x][r.y]='O';
								que.push(r);
							}
						}
					}
					for(int i=0;i<size[game];i++)
					{
						for(int j=0;j<size[game];j++)
							if(i==x&&j==y)
								cout<<"@";
							else
								cout<<gaming[z][i][j];
						cout<<endl;
					}
					while(press()!='\0');
					ch='\0';
					while(ch=='\0')
						ch=press();
					switch(loop[mirror[game]][ch-65])
					{
						case 'W':
							if(!gravity[game]||gaming[z][x][y]=='O')
							{
								x--;
								if(gaming[z][x][y]=='*')
								{
									if(gaming[z][x-1][y]=='#'||gaming[z][x-1][y]=='*'||gaming[z][x-1][y]=='E')
										x++;
									else
									{
										gaming[z][x][y]='.';
										if(gaming[z][x-1][y]!='!')
											gaming[z][x-1][y]='*';
									}
								}
								else if(gaming[z][x][y]=='#')
									x++;
							}
							break;
						case 'A':
							y--;
							if(gaming[z][x][y]=='*')
							{
								if(gaming[z][x][y-1]=='#'||gaming[z][x][y-1]=='*'||gaming[z][x][y-1]=='E')
								{
									y++;
									if(gravity[game])
									{
										x--;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											x++;
										else
										{
											y--;
											if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											{
												y++;
												x++;
											}
										}
									}
								}
								else
								{
									gaming[z][x][y]='.';
									if(gaming[z][x][y-1]!='!')
										gaming[z][x][y-1]='*';
								}
							}
							else if(gaming[z][x][y]=='#')
							{
								y++;
								if(gravity[game])
								{
									x--;
									if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										x++;
									else
									{
										y--;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										{
											y++;
											x++;
										}
									}
								}
							}
							break;
						case 'S':
							if(!gravity[game]||gaming[z][x+1][y]=='O'||gaming[z][x+1][y]=='*')
							{
								x++;
								if(gaming[z][x][y]=='*')
								{
									if(gaming[z][x+1][y]=='#'||gaming[z][x+1][y]=='*'||gaming[z][x+1][y]=='E')
										x--;
									else
									{
										gaming[z][x][y]='.';
										if(gaming[z][x+1][y]!='!')
											gaming[z][x+1][y]='*';
									}
								}
								else if(gaming[z][x][y]=='#')
									x--;
							}
							break;
						case 'D':
							y++;
							if(gaming[z][x][y]=='*')
							{
								if(gaming[z][x][y+1]=='#'||gaming[z][x][y+1]=='*'||gaming[z][x][y+1]=='E')
								{
									y--;
									if(gravity[game])
									{
										x--;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											x++;
										else
										{
											y++;
											if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											{
												y--;
												x++;
											}
										}
									}
								}
								else
								{
									gaming[z][x][y]='.';
									if(gaming[z][x][y+1]!='!')
										gaming[z][x][y+1]='*';
								}
							}
							else if(gaming[z][x][y]=='#')
							{
								y--;
								if(gravity[game])
								{
									x--;
									if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										x++;
									else
									{
										y++;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										{
											y--;
											x++;
										}
									}
								}
							}
							break;
						case 'C':
							eye=2;
							break;
						case 'R':
							x=y=z=eye=1;
							for(int i=0;i<size[game];i++)
								for(int j=0;j<size[game];j++)
									for(int k=0;k<size[game];k++)
										gaming[i][j][k]=maze[game][i][j][k];
							break;
					}
				}
				else
				{
					cout<<"视角:右视角"<<endl;
					if(gravity[game])
					{
						while(1)
						{
							box=false;
							for(int i=0;i<size[game];i++)
								for(int j=size[game]-1;j>=0;j--)
									for(int k=0;k<size[game];k++)
										if(gaming[i][j][k]=='*'&&(gaming[i][j+1][k]=='.'||gaming[i][j+1][k]=='!')&&!(i==z&&j+1==x&&k==y))
											box=true;
							if(!box)
								break;
							for(int i=0;i<size[game];i++)
							{
								for(int j=0;j<size[game];j++)
									if(i==x&&j==z)
										cout<<"@";
									else
										cout<<gaming[j][i][y];
								cout<<endl;
							}
							for(int i=0;i<size[game];i++)
								for(int j=size[game]-1;j>=0;j--)
									for(int k=0;k<size[game];k++)
										if(gaming[i][j][k]=='*'&&(gaming[i][j+1][k]=='.'||gaming[i][j+1][k]=='!')&&!(i==z&&j+1==x&&k==y))
										{
											gaming[i][j][k]='.';
											gaming[i][j+1][k]='*';
										}
							Sleep(200);
							system("cls");
							cout<<"关卡"<<game+1<<endl;
							cout<<"重力:";
							if(gravity[game])
								cout<<"开启"<<endl;
							else
								cout<<"关闭"<<endl;
							cout<<"镜像:";
							if(mirror[game]==0)
								cout<<"无"<<endl;
							if(mirror[game]==1)
								cout<<"左右"<<endl;
							if(mirror[game]==2)
								cout<<"上下"<<endl;
							if(mirror[game]==3)
								cout<<"特殊"<<endl;
							if(game==5)
								cout<<"本章拥有重力,所以W键和S键就废了。"<<endl;
							if(game==6)
								cout<<"你获得了爬楼梯的技能。"<<endl;
							if(game==7)
								cout<<"按R重开。"<<endl;
							if(game==11)
								cout<<"箱子也能拥有重力。"<<endl;
							if(game==12)
								cout<<"岩浆可以毁灭你和箱子,小心岩浆!"<<endl;
							if(game==20)
								cout<<"你可以在水里游泳。"<<endl;
							if(game==21)
								cout<<"箱子可以悬浮在水中。"<<endl;
							if(game==22)
								cout<<"水会流动。"<<endl;
							cout<<"视角:右视角"<<endl;
						}
						while(gaming[z][x+1][y]!='#'&&gaming[z][x+1][y]!='*'&&gaming[z][x+1][y]!='O')
						{
							for(int i=0;i<size[game];i++)
							{
								for(int j=0;j<size[game];j++)
									if(i==x&&j==z)
										cout<<"@";
									else
										cout<<gaming[j][i][y];
								cout<<endl;
							}
							x++;
							Sleep(200);
							if((gaming[z][x+1][y]=='#'||gaming[z][x+1][y]=='*'||gaming[z][x+1][y]=='O')&&gaming[z][x][y]=='E')
								break;
							if(gaming[z][x][y]=='!')
							{
								x=y=z=eye=1;
								for(int i=0;i<size[game];i++)
									for(int j=0;j<size[game];j++)
										for(int k=0;k<size[game];k++)
											gaming[i][j][k]=maze[game][i][j][k];
								break;
							}
							system("cls");
							cout<<"关卡"<<game+1<<endl;
							cout<<"重力:";
							if(gravity[game])
								cout<<"开启"<<endl;
							else
								cout<<"关闭"<<endl;
							cout<<"镜像:";
							if(mirror[game]==0)
								cout<<"无"<<endl;
							if(mirror[game]==1)
								cout<<"左右"<<endl;
							if(mirror[game]==2)
								cout<<"上下"<<endl;
							if(mirror[game]==3)
								cout<<"特殊"<<endl;
							if(game==5)
								cout<<"本章拥有重力,所以W键和S键就废了。"<<endl;
							if(game==6)
								cout<<"你获得了爬楼梯的技能。"<<endl;
							if(game==7)
								cout<<"按R重开。"<<endl;
							if(game==11)
								cout<<"箱子也能拥有重力。"<<endl;
							if(game==12)
								cout<<"岩浆可以毁灭你和箱子,小心岩浆!"<<endl;
							if(game==20)
								cout<<"你可以在水里游泳。"<<endl;
							if(game==21)
								cout<<"箱子可以悬浮在水中。"<<endl;
							if(game==22)
								cout<<"水会流动。"<<endl;
							cout<<"视角:右视角"<<endl;
						}
					}
					if(gaming[z][x][y]=='E')
						break;
					if(eye==1)
						continue;
					for(int i=0;i<game[size];i++)
						for(int j=0;j<game[size];j++)
							for(int k=0;k<game[size];k++)
								if(gaming[i][j][k]=='O')
								{
									t.x=j;
									t.y=k;
									t.z=i;
									que.push(t);
								}
					while(!que.empty())
					{
						t=que.front();
						que.pop();
						for(int i=0;i<=4;i++)
						{
							r.x=t.x+dx[i];
							r.y=t.y+dy[i];
							r.z=t.z+dz[i];
							if(gaming[r.z][r.x][r.y]=='.')
							{
								gaming[r.z][r.x][r.y]='O';
								que.push(r);
							}
						}
					}
					for(int i=0;i<size[game];i++)
					{
						for(int j=0;j<size[game];j++)
							if(i==x&&j==z)
								cout<<"@";
							else
								cout<<gaming[j][i][y];
						cout<<endl;
					}
					while(press()!='\0');
					ch='\0';
					while(ch=='\0')
						ch=press();
					switch(loop[mirror[game]][ch-65])
					{
						case 'W':
							if(!gravity[game]||gaming[z][x][y]=='O')
							{
								x--;
								if(gaming[z][x][y]=='*')
								{
									if(gaming[z][x-1][y]=='#'||gaming[z][x-1][y]=='*'||gaming[z][x-1][y]=='E')
										x++;
									else
									{
										gaming[z][x][y]='.';
										if(gaming[z][x-1][y]!='!')
											gaming[z][x-1][y]='*';
									}
								}
								else if(gaming[z][x][y]=='#')
									x++;
							}
							break;
						case 'A':
							z--;
							if(gaming[z][x][y]=='*')
							{
								if(gaming[z-1][x][y]=='#'||gaming[z-1][x][y]=='*'||gaming[z-1][x][y]=='E')
								{
									z++;
									if(gravity[game])
									{
										x--;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											x++;
										else
										{
											z--;
											if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											{
												z++;
												x++;
											}
										}
									}
								}
								else
								{
									gaming[z][x][y]='.';
									if(gaming[z-1][x][y]!='!')
										gaming[z-1][x][y]='*';
								}
							}
							else if(gaming[z][x][y]=='#')
							{
								z++;
								if(gravity[game])
								{
									x--;
									if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										x++;
									else
									{
										z--;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										{
											z++;
											x++;
										}
									}
								}
							}
							break;
						case 'S':
							if(!gravity[game]||gaming[z][x+1][y]=='O'||gaming[z][x+1][y]=='*')
							{
								x++;
								if(gaming[z][x][y]=='*')
								{
									if(gaming[z][x+1][y]=='#'||gaming[z][x+1][y]=='*'||gaming[z][x+1][y]=='E')
										x--;
									else
									{
										gaming[z][x][y]='.';
										if(gaming[z][x+1][y]!='!')
											gaming[z][x+1][y]='*';
									}
								}
								if(gaming[z][x][y]=='#')
									x--;
							}
							break;
						case 'D':
							z++;
							if(gaming[z][x][y]=='*')
							{
								if(gaming[z+1][x][y]=='#'||gaming[z+1][x][y]=='*'||gaming[z+1][x][y]=='E')
								{
									z--;
									if(gravity[game])
									{
										x--;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											x++;
										else
										{
											z++;
											if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
											{
												z--;
												x++;
											}
										}
									}
								}
								else
								{
									gaming[z][x][y]='.';
									if(gaming[z+1][x][y]!='!')
										gaming[z+1][x][y]='*';
								}
							}
							else if(gaming[z][x][y]=='#')
							{
								z--;
								if(gravity[game])
								{
									x--;
									if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										x++;
									else
									{
										z++;
										if(gaming[z][x][y]=='#'||gaming[z][x][y]=='*')
										{
											z--;
											x++;
										}
									}
								}
							}
							break;
						case 'C':
							eye=1;
							break;
						case 'R':
							x=y=z=eye=1;
							for(int i=0;i<size[game];i++)
								for(int j=0;j<size[game];j++)
									for(int k=0;k<size[game];k++)
										gaming[i][j][k]=maze[game][i][j][k];
							break;
					}
				}
			}
			system("cls");
			cout<<"第"<<game+1<<"关完成!";
			system("pause");
			game++;
		}
		system("cls");
		cout<<"您已完成本章所有关卡!";
		system("pause");
	}
	return 0;
}
1 个赞

连起来用,走迷宫高高高高高高高高高高高高高高级版

最好标题不要乱打,小心被举报有误导性

好^

sleep会报错啊

1 个赞

不错的游戏

2 个赞

《蒟蒻》

1 个赞

试过了

1 个赞

好了,但怎么玩?

1 个赞