Sign in to follow this  

Text with Direct Input

Recommended Posts

Crims0nSamurai    100
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!
[size="2"]strcpy(text, [/size][size="2"][color="#a31515"][size="2"][color="#a31515"]""[/color][/size][/color][/size][size="2"]);

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

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

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

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









Share this post

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

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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this