100 cls
200 w%=scw(0):h%=sch(0):side%=10:row%=(w%-2)/side%:column%=(h%-2)/side%
250 length%=3:dir%=1:index1%=0:index2%=length%-1
300 dim matrix%(row%*column%)
310 for i%=0 to length%-1:matrix%(i%)=(i%)*1000+column%/2:next i%
400 dr 0,0,row%*side%+1,column%*side%+1
500 for i%=0 to length%-1:dr matrix%(i%)/1000*side%+1,mod(matrix%(i%),1000)*side%+1,side%-2,side%-2
575 next i%
580 cube%=(abs(mod(rnd(0),row%)))*1000+abs(mod(rnd(0),column%)):pcube%=cube%
600 sl 100
625 sc 255,255,255
650 dr matrix%(index1%)/1000*side%+1,mod(matrix%(index1%),1000)*side%+1,side%-2,side%-2
700 if dir%=1 then matrix%(index1%)=matrix%(index2%)+1000
800 if dir%=2 then matrix%(index1%)=matrix%(index2%)-1
900 if dir%=3 then matrix%(index1%)=matrix%(index2%)-1000
1000 if dir%=4 then matrix%(index1%)=matrix%(index2%)+1
1100 index2%=index1%:index1%=mod(index1%+1,length%)
1125 sc 0,0,0:dr matrix%(index2%)/1000*side%+1,mod(matrix%(index2%),1000)*side%+1,side%-2,side%-2
1127 if matrix%(index2%)=cube% th gt 2400
1130 sc 255,0,0
1140 fr cube%/1000*side%+1,mod(cube%,1000)*side%+1,side%-2,side%-2
1200 if up(0) and dir%<>4 th dir%=2
1300 if down(0) and dir%<>2 th dir%=4
1400 if right(0) and dir%<>3 th dir%=1
1500 if left(0) and dir%<>1 th dir%=3
1975 if gameb(0) th gt 1975
1980 if gamea(0) th gt 100
1990 if gamed(0) th bye
2000 gt 600
2100 
2300 
2400 cube%=(abs(mod(rnd(0),row%)))*1000+abs(mod(rnd(0),column%)):length%=length%+1
2500 sc 255,255,255
2600 fr pcube%/1000*side%+1,mod(pcube%,1000)*side%+1,side%-2,side%-2
2650 pcube%=cube%
2700 gt 1125
2800 
2900 
3000 
3100 
3200 
3300 
3400 
3500 
3600 
3700 
3800 
3900 
4000 gt 4000