I'm working on a typing game written in C and ncurses.
The game asks player to enter lines of text.
If the input from the user is identical to the string, it then continue to ask the user to enter next line of string.
And I want to show a timer on the top of the screen to let user know how much time does he/she spend already.
Currently, the main architecture of the game is like this:
Main thread: 1. Use getstr() to get the input of the user
2. Check if the input string is correct
3. If yes, use printw() to print the next line of string.
Second thread: 1. Get current time
2. Save the current cursor position, use mvprintw() to print
current time at top of the screen and move() back to the
cursor position that has been saved before.
3. sleep() 1 seconds
However, when the user is typing, sometimes the character might be printed on top of the screen and the display of the game become messy.
Is there a better way that can fix the issue?