Refreshing a SINGLE character in Console?

I'm writing a game for the windows console, but the whole screen flickers whenever an action is performed. I ignored it until now, when my colleague said that it was "going to give someone a seizure". I actually agreed with him on that. So, is there any way to refresh individual portions of the console? Like turning the a in apple to uppercase, but without refreshing the rest of the word.

UPDATE: SOLVED! A billion and two thanks (and a cookie) to RFree75 for solving! It works incredibly well! Thanks!
Last edited on
You can move the cursor position with this:

#include <windows.h> //you'll need this

//use example: curPos(5,8); // will put the cursor 5 across and 8 down

void curPos(int x, int y)
{
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
GetConsoleScreenBufferInfo(hStdout, &csbiInfo);
csbiInfo.dwCursorPosition.X=x;
csbiInfo.dwCursorPosition.Y=y;
SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
}



As for displaying a single character:

#include <string>
#include <iostream>

cout << 'A';

or

cout << char(65); //will still print an A character (65 is ASCII number for A)

or

string yourString="ABCDEF";
cout << yourString.substr(3,1); //will print 1 char: D

Hope that helps
Last edited on
In the console? I don't think you can refresh any of it without using system("cls"), which is poor practice. If you're talking about in a window, look into buffering strategies. It will get rid of the flicker, but I don't know about how to refresh just a portion of a window. Im sure it's possible, web pages do it, but I'm not sure how to do it in C++.
Thx RFree75! That works incredibly well!
http://cplusplus.com/articles/G13hAqkS/

I like posting articles.
Well, ascii, the game is in fact a text-graphics one, and so far, I have been able to bend the console to the will of my game.

Mwahahahahaha.
I'm kind of curious about this haha. Should post some code :D or a video of this action
Topic archived. No new replies allowed.