this is a scope problem. all the varibles within the function are local and refreshed everythime the function is called (or set back to 0) which means your basicaly doing 0 + 0 & 0 - 0.
make x & y global and it should fix it.
[edit] in fact it does fix it :)
[edit 2]
you need to globalize and init the other varibles too, by bet :D
[extra note]why your first code works: the varibles are in the program scope. why your second code dont work: the varibles are in the function scope and as a result go out of scope when the function is exited and the varibles are re init when you cal the function again.
make x & y global and it should fix it.
[edit] in fact it does fix it :)
[edit 2]
Graphics 800,600,32 'load an image to tile Global image=LoadImage("flake.png") Global x, y Global duration = 500 'millisecs = 1/2 sec Global timer Global dx = 1, dy = 1 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
you need to globalize and init the other varibles too, by bet :D
[extra note]why your first code works: the varibles are in the program scope. why your second code dont work: the varibles are in the function scope and as a result go out of scope when the function is exited and the varibles are re init when you cal the function again.