For drawing rectangles to console, I have two functions. It draws a rectangle with ASCII chars :)
One sets the cursor position. The second one draws the rectangle.
The code:
#pragma once
#include <iostream>
#include <Windows.h>
BOOL setxy(int x, int y)
{
COORD c = {x,y};
return SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
void DrawRect(int x, int y, int width, int height, int curPosX=0, int curPosY=0)
{
setxy(x,y);cout << char(201);
for(int i = 1; i < width; i++)cout << char(205);
cout << char(187);
setxy(x,height + y);cout << char(200);
for(int i = 1; i < width; i++)cout << char(205);
cout << char(188);
for(int i = y + 1; i < height + y; i++)
{
setxy(x,i);cout << char(186);
setxy(x + width,i);cout << char(186);
}
setxy(curPosX,curPosY);
}
Copy the code in a header file -> then use in your projects or games :)