0

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?

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

thank you, I think I can do it using select()
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.