REM > RandWalk

ON ERROR ON ERROR OFF: OSCLI"ScreenSave RandImage": REPORT: PRINT "("+STR$ERL+")": END

MODE MODE
OFF

s% = 2

x% = 400
y% = 300

b% = &FF
g% = &FF
r% = &FF

 REPEAT
  REM ColourTrans_SetGCOL (3-351)
  SYS &40743, (b% << 24) + (g% << 16) + (r% << 8)
  CIRCLE FILL x% * 2, y% * 2, 4

   CASE RND(8) OF
    WHEN 1: y% += s%
    WHEN 2: x% += s%: y% += s%
    WHEN 3: x% += s%
    WHEN 4: x% += s%: y% -= s%
    WHEN 5: y% -= s%
    WHEN 6: x% -= s%: y% -= s%
    WHEN 7: x% -= s%
    WHEN 8: x% -= s%: y% += s%
   ENDCASE
  IF x% < 0 THEN x% = 800
  IF y% < 0 THEN y% = 600
  IF x% > 800 THEN x% = 0
  IF y% > 600 THEN y% = 0

  IF RND(2) = 1 THEN c% = 4 ELSE c% = -4
   CASE RND(3) OF
    WHEN 1: b% += c%
    WHEN 2: g% += c%
    WHEN 3: r% += c%
   ENDCASE
  IF b% < 0 THEN b% = 0
  IF g% < 0 THEN g% = 0
  IF r% < 0 THEN r% = 0
  IF b% > &FF THEN b% = &FF
  IF g% > &FF THEN g% = &FF
  IF r% > &FF THEN r% = &FF

 UNTIL 0

