Hello all,
It's been awhile since I last posted and I have a new idea for a program. I am looking to find out how progress bars work in the command promt or terminal. Linux users will know that when you install a program that it needs to download (in the terminal) it'll show you a progress bar like this: [====> ]. My question is this, how do they do it so it's not constantly refreshing everything, but still updating the progress bar? I am planning on making a couple of clocks and maybe even a text-based game if I can find out how this works. Thanks,
Ummmm maybe they only refresh it when its over every 10% or something...Although I don't know what kinds of functions are available in Linux for those kinds of things, someone else will probably be able to give you a better answer.
dunno... The wierd thing is it's accurate when you maximize the terminal too (proportions are correct, covers more ground when it gets bigger). And only in this little bar. Has anyone thought of doing a side-scrolling game using text? like mario but in cmd/terminal?
I don't remember the technical details, but the terminal has to be told when the window is resized. Then the terminal can query the width.
As for your first question, it is done one of two ways: either by using curses or by printing \h (backspace) to move the cursor backwards and rewriting the line.
Hey thanks for all your help. I took the progress bar you gave me and added a couple things and learned a couple of things. I never knew the '\b' character could be so useful. Looks like a side scrolling text baised game'll b alotta work though so I'm gonna start out with some real simple games. Thanks again!