Archived

This topic is now archived and is closed to further replies.

Ephimus

Keyboard input Question.

Recommended Posts

Hello. This may be a trivial problem, but I can''t figure it out. Anyway I am writing a little game in c/c++ and am using ddraw for graphics. My question is how do you do the equivalent to a scanf() function in a full screen ddraw application? I want the player to be able to input their name at a prompt from the game. I have looked around and have not been able to find any info on this. Could you please explain it or point me towards a tutorial or some source code? Thanks. Ephimus

Share this post


Link to post
Share on other sites
Use GetAsynchKeyState(). It should be in MSDN, although I got it from Windows Game Programming for Dummies. You need to & the return value with some constant to tell whether or not the key is pressed or released. I am sure someone has the KEY_DOWN() and KEY_UP() macros handy. They are in my vector graphics engine source code if you want to look at it. Follow the ROAD Programming link in my signature and click community then downloads. It is the only download. Since you seem to know DD and C, maybe you could check out my unfindable bug thread and help me out...

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

Share this post


Link to post
Share on other sites
You could also use the DirectInput and use the sdk docs for help. All you have to do a draw a prompt and a cursor which you blink at a set interval. Then use the the direct input functions to read keys and when a key is read display it with either a GDI function or something than move the cursor. You loop until the user as hit the enter key or something else and you can read every value entered. From this it is not difficult to create a backspace type like function. I do not have the code for all of this right now but if you still need more help let me know. ( For direct input help just look at the SDK or this site ).

Share this post


Link to post
Share on other sites

Thanks Guys. This will give me a start. Hopefully I can play around with it enough to get it working for me.


Bleakcabal -
I am using Win NT and I could not(after hours and hours of trying) get dinput to work under NT. If you have any advice in this area it would be appreciated.


Thanks.
Ephimus

Share this post


Link to post
Share on other sites
handle the WM_CHAR message in your message procedure - the wParam can be cast to a char (this has the advantage of standard keyboard repeat rates etc...)

Share this post


Link to post
Share on other sites
Just wondering why are you using Win NT to develop a game??

DirectInput not working under NT is no surprise...

:/

Cel

Share this post


Link to post
Share on other sites
NT rocks. It doesn't beat-pud or lockup or bluescreen nearly as often as 9x.

If I remember right, SP4 for NT4 included Dx5 support; so you can't use any Dx7 stuff in NT4, unless you a new sp has support for it. And you need SP4 for any Dx stuff to work.

Win2000 has Dx7 support.


Most people who code for M$ Windows code under NT.

Edited by - Magmai Kai Holmlor on October 3, 2000 10:52:24 PM

Share this post


Link to post
Share on other sites
Ya i know, I use win2k myself, but perhaps he hasnt installed the NT service packs thus not getting proper directx support....

Cel

Share this post


Link to post
Share on other sites