I was making this game on c++ in which coins keep on increasing and user can decide what to do with them, however the game stops for the user to enter the command. What i want is that coins keep on stacking up and if the user wishes to do something with them then he enters a number to perform the specific task.
Asked
Active
Viewed 100 times
-1
-
1so what is your question? – Cool_Coder Jan 20 '14 at 13:51
-
basically the game loop stops for the user if i use "cin" function. Which i don't want to happen. I want it to keep doing its process and if the user enters something then the game acts accordingly – Armaan Jan 20 '14 at 13:56
-
2Look at `cin.peek()` to see if a character is available without blocking. – CompuChip Jan 20 '14 at 14:02
3 Answers
0
From my understanding of the question and your comments, it seems you are trying to re-invent the wheel. You should take a look at Qt. It has its own eventloop which will handle the GUI for you.
If you do not want to use Qt then please multi thread your application so that the main thread is waiting for the cin while the other thread is running your coins.
PS: It would have been much more easier if you had posted your code.

Cool_Coder
- 4,888
- 16
- 57
- 99
0
Due the lack of information I'm just going to jump to the simplest answer.
USE THREADING
You could do something like this:
PSEUDOCODE WARNING:
MainThread:
Wait for user instructions
Lock Coins Variable
Expend their coins
Unlock Coins Variable
CoinThread:
Increase Coins all the time
Simple as that

felknight
- 1,383
- 1
- 9
- 25
-
If you need more information on how to use thread, please post you're code, or the language/platform you are using – felknight Feb 06 '14 at 16:22
-1
kbhit is the exact function, it sees if a parameter is available without stopping the program specifically for the command it is defined within the header file conio.h

Armaan
- 9
- 3