0

I'm trying to code the game of Simon(try to mimic the computers choice of four buttons) for a project. I'm kind of stuck because the computer generates a random choice, but I need to completely halt and wait for the user to enter his choice.(Done with the aswd keys; either up, down, left, or right) How can I do this? I'm trying to use _kbhit but it's not working as intended.

Any help would be greatly appreciated.

6
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by John A
0

Maybe because kbhit() doesn't read keys, it only tells you whether there is a key available.

To actually read it, use getch() or something like it (since you seem to be in DOS land).

0

To actually read it, use getch()

Oh... oh!. You are going to hear about this one. :)

0

Oh... oh!. You are going to hear about this one. :)

I don't get it. The only other alternative is to use some curses library.

0

I'm trying to code the game of Simon(try to mimic the computers choice of four buttons) for a project. I'm kind of stuck because the computer generates a random choice, but I need to completely halt and wait for the user to enter his choice.(Done with the aswd keys; either up, down, left, or right) How can I do this? I'm trying to use _kbhit but it's not working as intended.

Any help would be greatly appreciated.

Based strictly on this description, just read a line from the user. When he hits ENTER check the characters.

0

getchar(); the line just before return 0; works for me.

Dick

0

>getchar(); the line just before return 0; works for me.
Except we aren't talking about pausing the console after the execution is finished...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.