I'm not sure if you mean like this or not. But, I did this a while ago trying stuff out.
I imagine there's probably an better way to do this though.
Graphics 800,600,16,2 SetBuffer BackBuffer() AppTitle "Bouncey Ball Thing" boxsize=2 box_x = 20 ; negative so it will start OFF screen box_y = 100 randomx=Rnd(0,8) randomy=Rnd(0,5) While Not KeyHit(1) Cls Color (255,255,255) Rect box_x,box_y,boxsize,boxsize,1 Flip If box_x>=800 Then boxright=True If box_x<=0 Then boxright=False If box_y>=600 Then boxdown=True If box_y<=0 Then boxdown=False If boxright=False Then box_x=box_x+randomx Else box_x=box_x-randomx EndIf If boxdown=False Then box_y=box_y+randomx Else box_y=box_y-randomx EndIf Wend End
I imagine there's probably an better way to do this though.