2014-04-16 05:35:30

Hi all,

This question is mostly for developer's but any thoughts from non-developers are welcome as well.

At the moment I am working on a quick and dirty text adventure system written in C++ suitable for developing classic interactive fiction games similar to games like the Infocom text adventures like Zork, Arthur, Hitch Hikers Guide to the Galaxy, and so forth. Since I am not really a fan of the text adventure languages like Inform and AGT I have decided to create my own system in C++, but have run into a slight problem with the text adventure system.

In Dos/Windows if one wants to pause a screen of text all he or she has to do is call the _getch() function which will pause the out put until the enter or space key is pressed. Mac OSX and Linux have no such function and similar functionality has to be accessed through ncurses or another library like that. I am trying to come up with a pause function that will be completely cross-platform and will compile on any platform without having to involve ncurses or some other third-party solution. So what I have done in the meantime is use the standard cin input stream with a prompt that says, "press c to continue or q to quit." I am wondering if people are okay with this method of pausing the screen, or if some of you  developers knows of a better way to go about pausing the text  on screen let me know.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-04-16 14:19:02 (edited by robjoy 2014-04-16 14:19:46)

Hi,
That is exactly what ncurses does, just in a bit more elegant way.
I would personally have a buffer that receives text to print, from multiple sources all at once. For instance a status bar refresh in each second, text to print to the bottom of the screen, menu prompts in menu functions, etc. The buffer would keep track of the console size (screen size in this case, I assume), and once it receives more lines than it can print, it prints a more prompt, and pauses at N - Buffer_size - 1, N being the length of the text to print.
Of course you can add more variation, e.g. enter a number to jump to a specified screen, space or enter to continue, q to quit, go backwards, these are all up to you. Managing your own buffer ensures that you are in control all the time.
Just my two cents.

Rob

----------
Robjoy, AKA Erion
Visit my site for all the things I do and to contact me.
You can also stop by for a slice of Pi

2014-04-19 22:25:40

@tward: if you use stdio then getchar() is perfectly adequate for this job. If you are doing something more elaborate then you will have to roll your own if you want to maintain a consistent view (in which case you might as well use ncurses smile ).

Just myself, as usual.