1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
class Screen
{
public:
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;
SMALL_RECT Rect;
int screen_width;
int screen_height;
enum Hues
{
BLACK = 0,
BLUE = 1,
GREEN = 2,
CYAN = 3,
RED = 4,
PURPLE = 5,
DARK_YELLOW = 6,
DEFAULT = 7,
GREY = 8,
BRIGHT_BLUE = 9,
BRIGHT_GREEN = 10,
BRIGHT_CYAN = 11,
BRIGHT_RED = 12,
MAGENTA = 13,
YELLOW = 14,
BRIGHT_WHITE = 15
};
Screen(int w = 60, int h = 50) : screen_width{ w }, screen_height{ h }
{
SetWindow();
}
void SetWindow()
{
coord.X = screen_width, coord.Y = screen_height;
Rect.Top = 0, Rect.Left = 0;
Rect.Bottom = screen_height - 1; Rect.Right = screen_width - 1;
SetConsoleScreenBufferSize(hConsole, coord);
SetConsoleWindowInfo(hConsole, TRUE, &Rect);
}
void Cset(int x, int y, int c)
{
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(hConsole, coord);
SetConsoleTextAttribute(hConsole, c);
}
void SetColor(int c)
{
SetConsoleTextAttribute(hConsole, c);
}
void SetCursor(int x, int y)
{
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(hConsole, coord);
}
};
|