I am making a game and I have a console using AllocConsole()
.
I want to be able to write commands in the console and I dont really know how to get input without pausing the game loop. Do I need to separate in two threads or is there another way?
Asked
Active
Viewed 236 times
0

Qix - MONICA WAS MISTREATED
- 14,451
- 16
- 82
- 145

user3684561
- 13
- 2
1 Answers
1
You don't need to pause game loop. Just process the commands in the game loop as you do with keyboard, mouse, network, whatever. One thing you're probably afraid about is that I/O may block until sufficient data are available. If this is the case, you can turn on non-blocking I/O on standard input or you can use stuff like select()
to check if there are any data.

Zaffy
- 16,801
- 8
- 50
- 77
-
thank you, I think I can do it using select() – user3684561 May 28 '14 at 16:57
-
Bear in mind that, under Windows, `select()` is implemented over `WaitForMultipleObjects` so you have a default limit of 64 file handles you can select on. – kfsone May 28 '14 at 17:16