|
|
BSD 4.3
# WORM(6)
#
# Random worm
#
# Stephen B. Wampler
#
# Last modified 8/14/84
#
# NOTE: This program requires the procedures in gpack.2. It
# should be translated as follows:
#
# icont worm.icn /usr/icon/ilib/gpack.u1
#
global BLUE, WHITE
global VECTOR
procedure main(args)
local colpt, bkcolr, count, length, r, arg, a, pt1, pt2
ginit()
colpt := WHITE
bkcolr := BLUE
count := 1000
length := 10
r := 0
every arg := !args do case arg[1+:2] of {
"-f" : colpt := integer(arg[3]) # foreground color
"-b" : bkcolr := integer(arg[3]) # background color
"-c" : count := integer(arg[3:0]) # duration of worm
"-l" : length := integer(arg[3:0]) # length of worm
"-r" : r := integer(arg[3:0]) # random number seed
"-h" : stop("usage: worm [-fn] [-bn] [-cn] [-ln] [-rn]")
}
if colpt == bkcolr then {
colpt := WHITE
bkcolr := BLUE
}
a := point(XMAX/2,YMAX/2) # start in screen center
every (pt1|pt2) := create # two sequences of the same lines
2(&random :=: r,|draw(line(.a,a := nextpt(a))),&random <-> r)
bckgrnd(bkcolr)
erase()
every _noroll() & _plot() do {
mode(VECTOR)
color(colpt)
every 1 to length do @pt1
every 1 to count do {color(colpt);@pt1;color(bkcolr);@pt2}
color(bkcolr)
every 1 to length do @pt2
movcur(20,20)
color(colpt)
}
end
procedure nextpt(pt)
local x,y
repeat {
x := pt.x + (?32767\1)%21 - 10
if 0 < x < XMAX then break
}
repeat {
y := pt.y + (?32767\1)%21 - 10
if 0 < y < YMAX then break
}
return point(x,y)
end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.