More groovy patterns for Raspberry Pi

Following on from the last post about groovy patterns for Raspberry Pi, I present my latest program, another random walk.

It is a random walk similar to last time, however with this one there are three degrees of freedom (rather than horizontal and vertical) and rather than a line, the object displayed in a coloured 3D box.
This code is for BASIC V running under RISCOS on the Raspberry Pi. Copy the code, or download directly.

The code:

   10 REM Blocks
   20 REM T Street
   30 REM 2017-05-21
   40 :
   50 MODE 19
   52 delay = 0
   55 colcyc = 0
   60 angle1 = RAD(45): angle2 = RAD(20)
   70 size = 16
   72 LIMIT = 50
   73 DENSITY = 40
   80 xo=500:yo=500
   90 x = xo: y=yo
  100 dir = RND(5)
  110 PROCsetdir
  112 lc = 0
  114 dc = 0
  120 REPEAT
  140   PROCbox(x,y,size,angle1,angle2)
  141   t=TIME:REPEAT UNTIL TIME>t+delay
  150   x = x + dx: y = y + dy
  151   lc = lc + 1
  160   IF RND(6) = 1 THEN PROCchangeDir
  170   IF x<0 OR x>1000 OR y<0 OR y>1000 OR lc>LIMIT THEN
  180     x=xo:y=yo
  181     colcyc = colcyc+2: IF colcyc > 127 colcyc = 0
  182     lc = 0
  183     dc = dc + 1
  190   ENDIF
  191   IF dc>DENSITY THEN
  192     dc = 0:CLS:x=xo:y=yo:lc = 0
  193   ENDIF
  200 UNTIL FALSE
  210 END
  220 :
  230 DEFPROCbox(x,y,s,ar,au)
  240 REM draws a box at coords x,y
  250 REM where the coords are the lower left corner
  260 REM and s is the size of box
  270 REM and ar and au are angles
  280 MOVE x,y
  290 LOCAL up, right
  300 up = s*SIN(au)
  310 right = s*COS(ar)
  320 REM front side
  330 GCOL 2+colcyc
  340 MOVE x,y+s
  350 PLOT 85,x+s,y
  360 MOVE x+s, y:MOVE x, y+s
  370 PLOT 85, x+s, y+s
  380 REM right hand side
  390 GCOL 1+colcyc
  400 MOVE x+s+right, y+up: MOVE x+s, y+s
  410 PLOT 85, x+s, y
  420 MOVE x+s+right, y+up: MOVE x+s, y+s
  430 PLOT 85, x+s+right, y+s+up
  440 REM top
  450 GCOL 1+colcyc
  460 MOVE x+right, y+s+up: MOVE x+s, y+s
  470 PLOT 85, x, y+s
  480 MOVE x+right, y+s+up: MOVE x+s, y+s
  490 PLOT 85, x+s+right, y+s+up
  491 GCOL 0
  492 MOVEx,y:DRAW x+s,y:DRAW x+s,y+s:DRAWx,y+s:DRAW x,y
  500 ENDPROC
  510 :
  520 DEFPROCsetdir
  530 CASE dir OF
  540   WHEN 1
  550   dx = 0: dy = size
  560   WHEN 2
  570   dx = size: dy = 0
  580   WHEN 3
  590   dx = 0: dy = -size
  600   WHEN 4
  610   dx = -size: dy = 0
  620   WHEN 5
  630   dx = -(size*COS(angle2)): dy = -(size*SIN(angle2))
  635   WHEN6
  636   dx = (size*COS(angle2)): dy = (size*SIN(angle2))
  640 ENDCASE
  650 ENDPROC
  660 :
  670 DEFPROCchangeDir
  680 dir=RND(6)
  690 PROCsetdir
  700 ENDPROC
  710 :