我正在制作一个游戏(一个命令行游戏,不要杀了我),我正在添加一些东西来检查命令行文本的颜色,然后用我想要的任何bg颜色对它进行求和(bg颜色)是彩色* 16)来创建一个粗略的“指向”系统,
问题是:我如何从一个有选择性选择的网格(文本)中获取一个字符,然后读取它的颜色,用于赋予该角色与其他角色不同的背景?
#include <iostream>
#include <windows.h>
enum Color { DARKBLUE = 1, DARKGREEN, DARKTEAL, DARKRED,
DARKPINK, DARKYELLOW, GRAY, DARKGRAY, BLUE,
GREEN, TEAL, RED, PINK, YELLOW, WHITE};
void SetColor(int c){
HANDLE hCon = NULL;
if (hCon == NULL){
hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon, c);
}
}
void AdvSetColor(Color back,Color fore){
int c;
c = back * 16 + fore;
SetColor(c);
}
char sometext[10][10] ={
{"Lorem ipsum"},
{"dolor sit am"},
{"et, consect"},
{"etur adipis"},
{"icing elit,"},
{"sed do eiusm"},
{"od tempor inc"},
{"ididunt ut l"},
{"abore et dol"},
{"ore magna al"}, //highlight all the words that are broken inbetween the sets
}