I would prefer to do it by noting Millisecs() when the race starts (say, 'StartTime'), then subtract that value from Millisecs() and pass the result to a function to turn into a readable string. This accurately records minutes, seconds and thousandths of a second - you might want to modify it if all you need is hundredths:
Note: The "T" value passed to the function would be "Millisecs() - StartTime".
To get around the problem of pausing is easy. When you press the pause key, do "PauseStart = Millisecs()". When the player un-pauses the game, simply do "StartTime = StartTime + (Millisecs()-PauseStart)". This basically means the length of time the game was paused for, will be added onto the time recorded at the start of the race, compensating for the pause.
I've used this method in 3 racing games. It works well and its very accurate.
Function CalcTime$(T) If T > 59459998 TIM$ = "99:59.999" Return TIM$ EndIf S = Int(T / 1000) FS = T - (S*1000) M = S / 60 S = S - (M*60) If M > 99 M = 99 : S = 59 EndIf If M > 99 Then M = 99 If S > 59 Then S = 59 If FS > 999 Then FS = 999 MM$ = Str$(M) SS$ = Str$(S) FF$ = Str$(FS) If Len(MM) = 1 Then MM = "0" + MM If Len(SS) = 1 Then SS = "0" + SS If Len(FF) = 1 Then FF = "00" + FF If Len(FF) = 2 Then FF = "0" + FF TIM$ = MM + ":" + SS + "." + FF Return TIM$ End Function
Note: The "T" value passed to the function would be "Millisecs() - StartTime".
To get around the problem of pausing is easy. When you press the pause key, do "PauseStart = Millisecs()". When the player un-pauses the game, simply do "StartTime = StartTime + (Millisecs()-PauseStart)". This basically means the length of time the game was paused for, will be added onto the time recorded at the start of the race, compensating for the pause.
I've used this method in 3 racing games. It works well and its very accurate.