![]() |
Need help with user input
Hey all,
I'm making a small console game, and I'm looking for another way to get users input. I'm using the WASD keys to move a cursor on the screen, but the only way I know to get a users input is by using cin. As you can guess, having to press a direction key and then hit Enter is a bit time consuming on the users side and I was wondering if anyone can give me some help in finding another way to do this. I know this can be accomplished using ncurses, and probably other libraries. But I'd really like to stick with the standard C++ libraries if possible. Oswyn |
Not possible. There is no way in the standard C or C++ libraries to receive individual keystrokes. That's because the standard libraries are based around a pretty generic computing device (and, generically, a computing device may not have a keyboard).
If you are targeting a machine with a keyboard, most compilers you will be using and their libraries include functions that provide some means of obtaining keystrokes directly. You need to read your compiler and library documentation to find out how to do it. Keep in mind that the method varies between compilers and systems. If you want to use curses or similar, look up raw input. |
I was afraid that would be the case. I looked over some curses examples and came up with this, a pretty minimal solution, in case anyone is interested.
:
#include <ncurses.h> |
Quote:
|
| All times are GMT -5. The time now is 12:56 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC