I'm sorry to disturb you...
There's this little game I'm developing and I'm stuck.
So the game is about guessing a random number and I want to put a timer to see how long did the user to guess the number.
Here's the code for the timer:
Procedure Timer ;
Begin
time := 0 ;
While a <> b do
Begin
Writeln ('Seconds: ',time,'') ;
Delay (1000) ;
Inc (time) ;
ClrScr ;
"a" is the input number and "b" is the randomized number.
The problem is that the program keeps repeating the delay of 1 second and it doesn't let me input a number.
I thought on executing the main program and the procedure at the same time but I guess there is another way of doing it.
Here's the code for the rest of the game:
Program Guess_the_number ;
Uses crt ;
var a, b, time : Integer ;
Begin
ClrScr ;
Timer ;
b := 1 ;
b := random (100) ;
Writeln ('Write a number between 1 and 100:') ;
Repeat
Readln (a) ;
If a < b
then Writeln ('Too small...') ;
If a > b
then Writeln ('Too big...') ;
Until a = b ;
If a = b
then Writeln ('You did it! The correct number was ',b,'!') ;
Writeln ('You took ',time,' seconds to guess it.') ;
ReadKey ;
End ;
You guys have any ideas?