Timing changes query

BlitzMax Forums/BlitzMax Beginners Area/Timing changes query

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.

using for the image.

This works:
Graphics 800,600,32
'load an image to tile
image=LoadImage("flake.png")

duration=500 'millisecs = 1/2 sec

dx=1
dy=1

timer=MilliSecs()

While Not KeyHit(KEY_ESCAPE)

	TileImage image,x,y

	'move the tiled background
	x=x+dx
	y=y+dy
	
	If MilliSecs()>timer+duration
	dx=-dx
	dy=-dy
	timer=MilliSecs()
	End If
	
	Flip;Cls

Wend




while this doesn't:
Graphics 800,600,32
'load an image to tile
Global image=LoadImage("flake.png")




While Not KeyHit(KEY_ESCAPE)

	function1()
	
	Flip;Cls

Wend

Function Function1()
TileImage image,x,y
duration=500 'millisecs = 1/2 sec
timer=MilliSecs()

dx=1
dy=1
	'move the tiled background
	x=x+dx
	y=y+dy
	
	If MilliSecs()>timer+duration
	dx=-dx
	dy=-dy
	timer=MilliSecs()
	End If

End Function


I don't know why ? Am I right in asserting flip and cls should only be called once within a program? Any ideas or tips ?