How to Update a Content in a Console without Using System ("cls") or any other equivalents

In Fact Iam making a Game and I want to make a timer in it that counts up , and I want to make it updates the seconds and minutes without clearing the whole screen , with the Game operations .. Is That Possible ?
By the Way Iam using time_t Structure ..
Last edited on
Is That Possible ?

Yes technically, but I wouldn't encourage it. Windows has a way for you to update a portion of the screen (or "Region" as they call it) at a time but it's really a bit of a pain to manage and believe it or not it is actually easier to just clear the whole screen and redraw everything. Modern hardware is so far a head of the curve on rendering that functions like these aren't worth the effort they require outside of a mobile platform.
I don't necessarily agree with that. It is exceedingly easy to manage an active and inactive page and flip between them.

You do need to set it up, which is like three lines of code, maybe, and then tell windows to swap when appropriate, which I think is just one line.

However, the simple redraw-the-screen method is usually reasonably fast, especially on PCs. Here's an example of just redrawing the entire "region" (using a gotoxy-type function) that works well.
http://www.cplusplus.com/forum/lounge/75168/

[edit] Notice that I still maintain a separate buffer for what the screen will become.

Hope this helps.
Last edited on
Topic archived. No new replies allowed.