how does timing work?

Blitz3D Forums/Blitz3D Beginners Area/how does timing work?

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.

The only reason you get a wrong answer on this forum is because you've asked the wrong question...mostly ;o)

Is this what you're after?
Type rectangle
	Field r, g, b
	Field x, y, w, h
End Type

Graphics 640, 480, 0, 2
SetBuffer BackBuffer()

r_count = 0

time = MilliSecs()

Repeat
	Cls
	
	; If times up, add a new rectangle to the list
	If (MilliSecs() - time) >= 1000
		If r_count < 20
			r.rectangle = New rectangle
			r\r = Rand(255)
			r\b = Rand(255)
			r\g = Rand(255)
			
			r\x = Rand(539)
			r\y = Rand(379)
			r\w = Rand(100)
			r\h = Rand(100)
			
			r_count = r_count + 1
			time = MilliSecs()
		EndIf
	EndIf
	
	; Draw all the rectangles in the list
	For r.rectangle = Each rectangle 
		Color r\r, r\b, r\g
		Rect r\x, r\y, r\w, r\h, 1
	Next
	
	Color 255, 255, 255
	Text 0, 0, CurrentTime$()
	
	Flip
Until KeyHit(1)

End
YAN