problem calculating time

Blitz3D Forums/Blitz3D Programming/problem calculating time

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Edit:
The alternative would be checking the time more often.
Here is my version, it does exactly the same:
	Graphics 800, 600, 0, 2
	SetBuffer BackBuffer()
	
	Dim time#(4)
	
	init = True
	
	Repeat
	
		;calculate time passed
		now# = MilliSecs()
		If init Then prev# = now#: inittime# = now: init = False
		elapsed# = now# - prev#
		prev# = now#
		
		;select quadrant
		mx = MouseX()
		my = MouseY()
		quad = (mx > 400) + (my > 300) * 2
		;set time for selected quadrant
		time(quad) = time(quad) + elapsed
		
		;graphical output
		Cls
		
		;draw grid
		Line 400, 0, 400, 600
		Line 0, 300, 800, 300
		
		;print out times
		For i = 0 To 3
			Text i Mod 2 * 400 + 200, i / 2 * 300 + 150, time#(i) / 1000
		Next
				
		;measure total time passed
		tot1# = ((time(0) + time(1) + time(2) + time(3)) / 1000)
		tot2# = (MilliSecs() - inittime#) / 1000

		;debug output		
		Text 0,  0, "You're in quadrant: " + quad
		Text 0, 20, "Total sum times:      " + tot1#
		Text 0, 40, "Total time millisecs: " + tot2#
		
		Flip

		;limit to 60 secs			
		If tot2# >= 60 Then Exit
	
	Until KeyHit(1)
	
	Text 400, 300, "GAME OVER", True, True
	
	WaitKey()
	
	End

/edit