#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;
}
为什么运行后是黑屏,没有图案