previous

page 26

next

Moving right on - modify pursuit to produce: click for my code

function pursuit(n) {
var colrs=['red','orange','yellow','lime','lightblue','violet',
'cyan','magenta','pink','khaki'];
bg('black');
var pts=points(n);
var t=[];
for (var i=0; i<n; i++) {
t[i]=turtle();
t[i].x=pts.x[i];
t[i].y=pts.y[i];
}
for (var j=0;j<1000;j++) {
for (var i=0; i<n; i++) {
var k=i+1;
if (k==n) k=0;
towards(t[i],t[k]);
var cn=i%colrs.length;
pc(t[i],colrs[cn]);
join(t[i],t[k]);
fd(t[i],1);
}
}
}
previous
next