Would this Work?
D$ = "UP"
Do
If D$ = "UP" Then Offset Sprite 1,0,-1
If D$ = "DOWN" Then Offset Sprite 1,0,1
If Sprite Y(1) = 0 Then D$ = "DOWN"
If Sprite Y(1) = 100 Then D$ = "UP"
Loop
Or
D1$ = "UP"
D2$ = "UP"
Do
If D1$ = "UP" Then Offset Sprite 1,0,-1
If D1$ = "DOWN" Then Offset Sprite 1,0,1
If Sprite X(1) <= 0 Then D1$ = "DOWN"
If Sprite X(1) => Screen Width() Then D1$ = "UP"
If D2$ = "UP" Then Offset Sprite 1,-1,0
If D2$ = "DOWN" Then Offset Sprite 1,1,0
If Sprite Y(1) <= 0 Then D2$ = "DOWN"
If Sprite Y(1) => Screen Height() Then D2$ = "UP"
Loop