+ 1
Status Bar in C++ Console
Alright. I don't know how many of you are old enough to actually get what I'm asking here... But back in the day, when all of our games were DOS, some of them like Zork or King's Quest would have a status bar at the top of the screen that displayed the name of the game and your score. How would I recreate that in a standard Windows Console? It's just a white line at the top of the screen that has black text and I can't figure out how to keep it from moving whenever a new part of the game loads.
3 Antworten
+ 4
You will have to either keep on reprinting the status bar every time you make changes in the game, at the same position as before by using SetConsoleCursorPosition; or you may just print it once and declare an update area. You will have to store its initial coordinates, and print on only the marked area. This way, your bar remains safe. If you need to update the bar, you may set the cursor on it, and reprint the bar.
See this program. I have a log area to raise prompts. I just set my cursor to the area's begining, print my line, and then clear it when its use is finished, without even touching the rest of the console... See the function ClearLog for more info...
void ClearLog()
{
ShowCursor(FALSE);
SetCursorAt(100,55);
cout<<" ";
SetCursorAt(100,55);
}
https://code.sololearn.com/cAlNxwpPFqST/?ref=app
+ 1
depends on how your game works .
1. is your game clear the console and output all over again every 0.01s ?
2. are you using /r ?
if you'll provide a code maybe I could help.
+ 1
Alright. I haven't started writing yet. Just working out ideas. I'm thinking about using pdcurses for now and eventually figuring out mfc or wxwidgets.
I also didn't realise you could set separate areas for updating. Thanks.