Okay, here's what I want to do - when the player is at the main menu, I want them to be able to type in cheat codes. That's the only place I want it to work. I don't want to give them a text box to type into. Rather, I want them to simply type in a word (let's say "cheat", just for simplicity sake) that activates the cheat code. I only need to capture keyboard input when the window is in focus. What can I do to accomplish this?
Tell me more
×
Game Development Stack Exchange is a question and answer site for
professional and independent game developers. It's 100% free, no registration required.
|
|
You know your keywords. So store those in a string array. Store every key press into a char array and read the sequence. Allow a time out that clears the array. Compare your char string to any of the cheat keywords. When a match is found you call your cheat function. |
|||
|
|
|
Given the complete lack of implementation details provided, I'd simply say that you get the keyboard state just like you would during your normal game play, you remember which keys were pressed in order, and if the player is in the menu and a cheat code is recognized, you do stuff. |
|||
|
|
