Dear forum members,
my best wishes and a happy newyear to you all!!
It's the first day of the year and already I have some C problems...lol
I have to make a game for school. The game shows the player a number and gives the player a few seconds to remember the number. Than the screen is cleared and the number is asked.
A little piece of code with a problem :
When my program is being halted by the do while loop, the user cannot type the number because the screen will not adjust. When he presses a button and hits enter, nothing happens, until the time is passed. But once the time is passed, everything the player typed during the time the program was halted is being accepted by the program. So he can type in the number before the screen is being cleared and cheat! Once the time is over, the program will accept the number the player entered during the halted period.
//A random number between 1 and 4 is being generated
tab1[i] = ((rand()%4)+1);
//The player gets to see the number + the time he has to study it
printf ("New number is = %d\n", tab1[i]);
printf ("You've got %2d sec to study the number\n", 2+i*2);
//The program is being halted for a few seconds by a do while, afterwards the screen is cleared
while((cur_time - start_time) < 2+i*2);
//The user has to type the same number
printf ("Please enter the corrent number*\n");
It's complicated to explain and my english is poor lol! I hope you guys understand:s I can explain this in more detail if my text doesn't make sense...héhé
The thing I want to do is: While my program is being halted by the do while, I want to disable user input. Or maybe I can halt the program in another way, so that it comes down to the same point. I'm using borland to program. I cannot use foreign libraries, only the standard ones...
I tried functions like Msleep(), sleep(), delay(), ... But I can't get them to work with the libraries I have...
I hope someone can help me Thanks anyway
Have a nice day