- function updateScurry(c) {
- for (i=0;i<c.imageCount;i++) { // direction 0=right 1=left
- var newX = getLayerX(c.prefix + i) + ((c.direction[i] * 2) - 1) * (-c.speed2[i]);
- var newY = getLayerY(c.prefix + i);
- if (c.direction[i] == 1 && newX < getViewXOffset()) { var done = 1; }
- else if (c.direction[i] == 0 && newX > getViewXOffset() + getViewWidth() - c.imageWidth) { var done = 1; }
- else { var done = 0; }
- if (done) {
- c.direction[i] = random(2);
- c.speed2[i] = c.speed + random(4);
- var newX = getViewXOffset() + c.direction[i] * (getViewWidth() - c.imageWidth)
- var newY = getViewYOffset() + random(getViewHeight() - c.imageHeight)
- }
- moveLayer(c.prefix + i, newX, newY);
- }
- setTimeout("updateScurry(c" + c.uid + ")", c.updateDelay);
- }
Raw Paste