• Advertisement
Sign in to follow this  

Text with Direct Input

This topic is 2469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm currently working on a game where text input is required, mainly for save game names. I'm using the following code, but what ends up happening is letters repeat until the end of the array :/ any help would be much appreciated!
[color="#0000ff"][color="#0000ff"]
strcpy(text, [color="#a31515"][color="#a31515"]"");



[color="#0000ff"][color="#0000ff"]int cc = 0;

[color="#0000ff"][color="#0000ff"]bool done = [color="#0000ff"][color="#0000ff"]false;

lpdikey->GetDeviceState(256, (LPVOID)keyboard_state);

[color="#0000ff"][color="#0000ff"]while[color="#000000"] (done==[color="#0000ff"][color="#0000ff"]false[color="#000000"])

{

[color="#0000ff"][color="#0000ff"]if(keyboard_state[DIK_A])

{

message[cc]=[color="#a31515"][color="#a31515"]'a';

fDrawText(200,400,text,2,lpddsBack);

cc++;

}



Share this post


Link to post
Share on other sites
Advertisement
This is because you have an infinite loop while(done==false) and you don re-poll the keyboard in the loop. So, the if statememt is still acting on the previous result.

You should either put the keyboard poll inside the loop or put done=true after your c++ line.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement