Groovy patterns for Raspberry Pi

In a spare moment whilst I was waiting for some food to cook, I decided to play with the BASIC on the Raspberry Pi. I'm using the brilliant RISCOS for the Pi which comes with BASIC V and about a gigabyte of RAM.

I decided to create a 'random walk' in an attempt to create something that would look like an abstract map of a city. I am quite pleased with the results.

Pictures first, and then the code.

It's supposed to look sort of 3D, sort of.

It really pelts along on my Raspberry Pi
When the line wanders off the screen it starts again in the middle of the pattern with a slight offset and a new colour. Lines sometimes quit and start again (controlled by the variable LIMIT%, and after a while the pattern will refresh (controlled by the DENSITY% variable).

Here is the source code for RISCOS BASIC V, which will require only minor modification to run in BBC BASIC for Windows, or on a BBC Master.

Copy the code below, or download the file directly.

   10 REM Draws a 'city scape'
   20 REM T Street
   30 REM 2017-05-10
   40 MODE 19
   50 ONERROR IF ERR=17 OSCLI("*DESKTOP")
   60 colCycle%= 0
   70 GCOLRND(4)+colCycle%
   80 REPEAT
   90   refresh%=FALSE
   99   REM Origin
  100   xo = 500 :yo = 500
  109   REM start at origin
  110   x = xo :y = yo
  119   REM distance moved each step
  120   dx=0:dy=0
  130   m = 16
  139   REM counts number of steps
  140   c = 0
  150   l=0
  160   LIMIT% = 400
  170   DENSITY% = 32
  180   MOVE x,y
  190   REPEAT
  200     c=c+1:l=l+1
  210     x=x+dx
  220     y=y+dy
  230     DRAW x,y
  240     r = RND(4)
  250     IF r=1 dx = 0:dy=m
  260     IF r=2 dx = m:dy=0
  270     IF r=3 dx = 0:dy=-m
  280     IF r=4 dx = -m:dy=0
  290     IF x<0 OR x>1000 OR y<0 OR y>1000 OR c>LIMIT%  THEN
  300       xo = xo+2:yo=yo+2
  310       x=xo
  320       y=yo
  330       c=0
  340       MOVE x,y
  350       GCOLRND(4)+colCycle%
  360     ENDIF
  370     IF l>LIMIT%*DENSITY% THEN
  380       refresh% = TRUE
  390     ENDIF
  400   UNTIL refresh%
  410   colCycle% = colCycle% + 4: IF colCycle% > 128: colCycle% = 0
  420   CLS
  430 UNTIL FALSE