#include #include #include using std::string; #include "Screen.h" namespace { HANDLE hStdout = 0; } void Screen::write(string s, int x, int y, int color) { if (hStdout == 0) { hStdout = GetStdHandle(STD_OUTPUT_HANDLE); } COORD screenPos; screenPos.X = x; screenPos.Y = y; unsigned long ln; static unsigned short attrib[80]; for (unsigned int i = 0; i < s.length(); ++i) { attrib[i] = color; } WriteConsoleOutputAttribute(hStdout, attrib, s.length(), screenPos, &ln); WriteConsoleOutputCharacter(hStdout, s.c_str(), s.length(), screenPos, &ln); }