Neat CLI graphics?

AFB

Lifer
Jan 10, 2004
10,718
3
0
How do you do things like prgress bars that move backwards(Left to right)?
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
There's a way to access the screen as a matrix, instead of just using printf/cout. I don't remember how. On windows, use WriteConsoleOutputCharacter

Some code from something my brother and I wrote a long time ago:
// Init the window stuff
hConsoleOut = GetStdHandle( STD_OUTPUT_HANDLE );
hConsoleIn = GetStdHandle( STD_INPUT_HANDLE );
GetConsoleScreenBufferInfo( hConsoleOut, &csbiInfo );

// Just cause
SetConsoleMode(hConsoleIn, ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT);

void draw(int x, int y, char c, WORD color)
{
COORD Coords;
DWORD Dummy;

Coords.X = x;
Coords.Y = y;

WriteConsoleOutputCharacter( hConsoleOut, &c, 1, Coords, &Dummy );
WriteConsoleOutputAttribute( hConsoleOut, &color, 1, Coords, &Dummy );
}