#include<bits/stdc++.h>
#include<iostream>
#include<bitset>
#include<windows.h>
#define an(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
int x = 1, y = 1;
int main() {
system("pause");
int dt[10][33] = { //1是墙 5是我 2是铁 3是钻 4是火 6是终点 7是药 8是炸药
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,5,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,0,1},
{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,7,0,0,0,3,0,0,1},
{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,0,1},
{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,0,1},
{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,0,1},
{1,0,0,0,0,0,0,0,0,1,0,0,4,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,0,1},
{1,0,4,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,0,1},
{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,3,0,6,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
while (true) {
if (an('M') && dt[x][y + 1] != 2 && dt[x][y + 1] != 3 && dt[x][y + 1] != 4 && dt[x][y + 1] != 7) {
if (dt[x][y + 1] == 1) {
dt[x][y + 1] = 0;
}
swap(dt[x][y], dt[x][y + 1]);
y++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
if (an('S')) {
if (dt[x + 1][y] == 6) {
system("cls");
Sleep(2000);
cout << "胜利" << endl;
system("pause");
return 0;
}
if (dt[x + 1][y] == 4 || dt[x + 1][y] == 7 || dt[x + 1][y] == 8) {
if (dt[x + 2][y] == 0) {
swap(dt[x + 1][y], dt[x + 2][y]);
swap(dt[x][y], dt[x + 1][y]);
x++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
else {
if (dt[x + 1][y] == 0) {
swap(dt[x][y], dt[x + 1][y]);
x++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
}
if (an('W')) {
if (dt[x - 1][y] == 4 || dt[x - 1][y] == 7 || dt[x - 1][y] == 8) {
if (dt[x - 2][y] == 0) {
swap(dt[x - 1][y], dt[x - 2][y]);
swap(dt[x][y], dt[x - 1][y]);
x--;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
else {
if (dt[x - 1][y] == 0) {
swap(dt[x][y], dt[x - 1][y]);
x--;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
}
if (an('D')) {
if (dt[x][y + 1] == 6) {
system("cls");
Sleep(2000);
cout << "胜利" << endl;
system("pause");
return 0;
}
if (dt[x][y + 1] == 8 && dt[x][y + 2] == 3) {
dt[x][y + 2] = 0;
dt[x][y + 1] = 0;
}
if (dt[x][y + 1] == 4 && dt[x][y + 2] == 2) {
dt[x][y + 2] = 0;
swap(dt[x][y + 1], dt[x][y + 2]);
swap(dt[x][y], dt[x][y + 1]);
y++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
if (dt[x][y + 1] == 4 && dt[x][y + 2] == 7) {
dt[x][y + 2] = 8;
dt[x][y + 1] = 0;
swap(dt[x][y], dt[x][y + 1]);
y++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
if (dt[x][y + 1] == 4 || dt[x][y + 1] == 7 || dt[x][y + 1] == 8) {
if (dt[x][y + 2] == 0) {
swap(dt[x][y + 1], dt[x][y + 2]);
swap(dt[x][y], dt[x][y + 1]);
y++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
else {
if (dt[x][y + 1] == 0) {
swap(dt[x][y], dt[x][y + 1]);
y++;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
}
if (an('A')) {
if (dt[x][y - 1] == 4 || dt[x][y - 1] == 7 || dt[x][y - 1] == 8) {
if (dt[x][y - 2] == 0) {
swap(dt[x][y - 1], dt[x][y - 2]);
swap(dt[x][y], dt[x][y - 1]);
y--;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
else {
if (dt[x][y - 1] == 0) {
swap(dt[x][y], dt[x][y - 1]);
y--;
system("cls");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 30; j++) {
if (dt[i][j] == 1) {
cout << "墙";
}
else if (dt[i][j] == 5) {
cout << "我";
}
else if (dt[i][j] == 0) {
cout << " ";
}
else if (dt[i][j] == 4) {
cout << "火";
}
else if (dt[i][j] == 2) {
cout << "铁";
}
else if (dt[i][j] == 3) {
cout << "钻";
}
else if (dt[i][j] == 6) {
cout << "终";
}
else if (dt[i][j] == 7) {
cout << "药";
}
else if (dt[i][j] == 8) {
cout << "炸";
}
}
cout << endl;
}
cout << "按n可以拿东西,按m冲撞";
}
}
}
Sleep(100);
}
return 0;
}
麻烦大 佬帮我把这些代码改成不会闪屏的,双缓存文章实在看不懂