umm.. I'm above AP.. was too lazy to type in name & pwd
hhm.... I found the query for a pressed key in one source
file of LaMothe's done like this:
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
put into your function it was:
bool keystate(int vk_code)
{
return (((GetAsyncKeyState(vk_code) & 0x8000) !=0) ? true : false)
}
I don't know if the missing & x8000 is the problem.
Try it, and let me know.
....................................................................................
EDIT:
No, it's at least not the only problem.
See my 3rd post below!
....................................................................................
When exactly do you read in a whole line?
Reading a line with cin, the characters are always displayed on the text screen, right?
However, some tips:
...if (keystate(49) == TRUE)...
you don't need to pick up the character's ASCII values of a book or so,
the compiler turns the chars into its corresponding number.
Just type: keystate( '1' )
The compiler will turn '1' into 49 for you.
I see, you're using a lowercase "bool" with your function.
So I assume, your C++ compiler has "bool", "true", "false" keywords defined by default.
Where "true" and "false" are constants of the type "bool".
TRUE and FALSE are defined by you.
Don't use TRUE together with bool.
Since "true" actually is also just stored as a number != 0, it works, of course.
But they don't belong together, you already have "true" and "false" defined,
so, use them.
(I think every recent compiler has bool defined, so, you won't need your TRUE
and FALSE definitions any longer)
And, for keystate() already returns a logical value, namely "true" or "false",
you don't need to compare the result with another logical value.
"if" decides on logical expressions, and keystate(x) is such one.
So, " if (keystate(x)) " does the same thing (I guess you knew this, though).
Maybe "KeyDown" is a better name for the function.
A decision based on " if ( KeyDown(key_code) ) " seems much more
intuitive than " if ( keystate(key_code) ) " or " keystate(code) == true "
(the words "keystate" and "true" don't sound that meaningful in conjunction,
do they? )
I'm not at home yet. When I'll have arrived, and still noone
helped you with your key-input problem, you can mail the entire code
to me, if you want. (or you could just post it, unless it's top secret

)
hope anything of my post was useful at all.
[edited by - UnshavenBastard on April 25, 2002 8:22:24 AM]