Search code examples
c++game-loop

game-loop stops and waits for the user


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.


Solution

  • 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