I am making a textual RPG game with Visual Studio in Python, where all the story is printed in the python command window with the print()
function. And sometimes, I ask the Player to make some choices with the input()
function.
The problem is, when the Player taps anything during the print (I use the time.sleep()
between print for style), all these inputs are saved until the next input()
call.
For example :
print("You're going to fight")
time.sleep(1)
#player tap 'sdlkem ENTER' during this time
print("What do you want to do")
input("Your choice: ")
#the console tap automatically 'sdlkem ENTER' and process it
I first search for a solution to disable keyboard, and found How to temporarily disable keyboard input using Python.
It was interesting but none of the solutions suited my issue because I can't nor disable printing, neither disable the keyboard forever...
Any ideas or alternatives?