YCL708118 2023-05-26 23:20 采纳率: 100%
浏览 12
已结题

关于#c++#的问题,请各位专家解答!

@一块铌金属

#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
 
using namespace std;
 
int x, y;
char mp[45][45];
int diffculeClass, flourColor, wallColor, peopleColor;
bool nonEuclid;
int canSeeCircle = 5;
string level = "0";
 
void color(int m) {
    HANDLE consolehend;
    consolehend = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(consolehend, m);
}
 
void Clear_Screen() {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = {0, 0};
    SetConsoleCursorPosition(hConsole, coordScreen);
}
 
void print(char c) {
    switch (c) {
        case '0':
            color(flourColor);
            printf("  ");
            break;
        case '1':
            color(wallColor);
            printf("■");
            break;
        case '2':
            color(peopleColor); 
            printf("♀");
            break;
    }
}
 
void newMap() {
    freopen("D:/programming/dev-c++/游戏/Backrooms/Level.txt", "r", stdin);
    while (1) {
        string lev;
        cin >> lev;
        if (lev == level) {
            scanf("%d%d%d%d", &diffculeClass, &flourColor, &wallColor, &peopleColor);
            cin >> nonEuclid;
            for (int i = 0; i < 42; i++) {
                cin >> mp[i];
            }
            break;
        } else {
            scanf("%d%d%d%d", &diffculeClass, &flourColor, &wallColor, &peopleColor);
            cin >> nonEuclid;
            char temp[45];
            for (int i = 0; i < 42; i++) {
                cin >> temp;
            }
        }
    }
}
 
void newXY() {
    mp[x][y] = '0';
    x = rand() % 43;
    y = rand() % 43;
    while (mp[x][y] == '1' or !(x >= 0 && x < 42 && y >= 0 && y < 42)) {
        x = rand() % 43;
        y = rand() % 43;
    }
}
 
void check(int adx, int ady) {
    if (mp[x + adx][y + ady] != '1') {
        mp[x][y] = '0';
        x = x + adx;
        y = y + ady;
        mp[x][y] = '2';
    }
} 
 
int main() {
    srand(time(0));
    SetConsoleTitle("Backrooms         制作:一块铌金属");
    system("mode con cols=90 lines=50");
    char c;
    newMap();
    newXY();
    mp[x][y] = '2';
    while (1) {
        c = _getch();
        if (c == 'w') {
            check(-1, 0);
        } else if (c == 's') {
            check(1, 0);
        } else if (c == 'a') {
            check(0, -1);
        } else if (c == 'd') {
            check(0, 1);
        } else if (c == 'q') {
            break;
        }
        for (int i = x - canSeeCircle; i < x + canSeeCircle + 1; i++) {
            for (int j = y - canSeeCircle; j < y + canSeeCircle + 1; j++) {
                if ((x - i) * (x - i) + (y - j) * (y - j) <= canSeeCircle * canSeeCircle && i >= 0 && i < 42 && j >= 0 && j < 42) {
                    print(mp[i][j]);
                } else {
                    color(0xF);
                    printf("  ");
                }
            }
            printf("\n");
        }
        if (nonEuclid) {
            int random = rand() % 101;
            if (random <= 1) {
                newXY();
            }
        } 
        Clear_Screen();
    }
    return 0;
}

为什么运行后是黑屏,没有图案

  • 写回答

3条回答 默认 最新

  • 一块铌金属 2023-05-27 00:53
    关注

    如果你是直接拷的代码是不行的,我发了个资源,里面有打包好的文件

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 6月4日
  • 已采纳回答 5月27日
  • 创建了问题 5月26日

悬赏问题

  • ¥20 ic卡dump文件校检码解密
  • ¥15 关于:接收到的数据不是有效的JSON格式
  • ¥15 apdl语言如何增加受力分析
  • ¥15 算法对比:学校优化算法与蚁群算法对比
  • ¥15 机电一体化系统设计说明书
  • ¥20 sgy数据提取地震波速,有人能回答吗小馋
  • ¥20 c#实现打开word的功能,并且需要安装成windows服务,word打不开怎么办
  • ¥15 python用ARIMA时间预测模型预测数据出错,急!
  • ¥30 为什么后端传给前端vue的河流json数据不在地图中显示出来
  • ¥50 关于弹性波动方程求解的问题: