'chapter 12 'qix line drawing 'requires CyBasic-2 'see below for CyBasic-1 dim n as int print "Number of lines" input n dim n1 as int dim n2 as int n1=n-1 n2=n1-1 dim x0[n] as int dim y0[n] as int dim x1[n] as int dim y1[n] as int dim dx0 as int dim dy0 as int dim dx1 as int dim dy1 as int dim seed as int sub newdirection(j as int) if (x0[j] < -80 or x0[j] > 80) then dx0 = -dx0 end if if (x1[j] < -80 or x1[j] > 80) then dx1 = -dx1 end if if (y0[j] < -43 or y0[j] > 43) then dy0 = -dy0 end if if (y1[j] < -80 or y1[j] > 80) then dy1 = -dy1 end if end sub ' for cybasic1 do the following ' dx0=-3 ' dx1=-1 ' dy0=1 ' dy1=2 'and remove the while loops... ' select random motion offsets while dx0=0 dx0 = 4-rnd(9) wend while dx1=0 dx1 = 4-rnd(9) wend while dy0=0 dy0 = 4-rnd(9) wend while dy1=0 dy1 = 4-rnd(9) wend 'select initial random line x0[0] = rnd(80) x1[0] = rnd(80) y0[0] = rnd(43) y1[0] = rnd(43) line x0[0], y0[0], x1[0], y1[0] cls 'fill up queue with trailing lines and print them for i=1 to n-1 x0[i] = x0[i-1] + dx0 x1[i] = x0[i-1] + dx1 y0[i] = y0[i-1] + dy0 y1[i] = y1[i-1] + dy1 line x0[i], y0[i], x1[i], y1[i] newdirection(i) next for i=0 to 1 step 0 ink 0 line x0[0], y0[0], x1[0], y1[0] ink 3 for j=1 to n-1 x0[j-1] = x0[j] x1[j-1] = x1[j] y0[j-1] = y0[j] y1[j-1] = y1[j] next x0[n1] = x0[n2] + dx0 y0[n1] = y0[n2] + dy0 x1[n1] = x1[n2] + dx1 y1[n1] = y1[n2] + dy1 line x0[n1], y0[n1], x1[n1], y1[n1] newdirection(n1) next