Alternatives to the console?

Started by
2 comments, last by Kuraitou 15 years, 8 months ago
Are there any good alternatives to the standard console for writing text based games in c++? I'd like to seperate the input from the output so to speak, so i can have my game running real time. The problem is that fetching commands using cin would make my game wait for the user to finish his input while nothing happens on screen. I'd like to have it working more like any irc program where you can type in text on the bottom while the window above scrolls independently. My hacky temporary solution is to just wait until the user hits a key with kbhit() before using cin, but even that is kinda lame as everything still freezes up while you're typing. So, any ideas?
Advertisement
You can look into the curses libraries, pdcurses on Windows and ncurses on Linux. They keep you in the console, but give you a lot more control. Alternatively you can look into some simple UI work with libraries like GTK+, wxWidgets, and QT 4.

EDIT: You can also use ANSI escape codes.
You could use only kbhit(), and then with getch() catch the pressed key. Keep the keys in a buffer until you detect an enter. Or however you want to handle it.

That way, you can retrieve whole words from the user, but still keep pumping your update loop. :)
If you want to do real-time input then you'll want something like this:

if (_kbhit() && m_inputActive){	int key = _getch();	OnKeyDown(key);}


EDIT: Beat to it. ;_;

This topic is closed to new replies.

Advertisement