JAVASCRIPT   30
updateScurry
Guest on 10th February 2023 01:36:30 AM


  1. function updateScurry(c) {
  2.  for (i=0;i<c.imageCount;i++) {   // direction 0=right 1=left
  3.   var newX = getLayerX(c.prefix + i) + ((c.direction[i] * 2) - 1) * (-c.speed2[i]);
  4.   var newY = getLayerY(c.prefix + i);
  5.   if (c.direction[i] == 1 && newX < getViewXOffset()) {  var done = 1; }
  6.   else if (c.direction[i] == 0 && newX > getViewXOffset() + getViewWidth() - c.imageWidth) {  var done = 1; }
  7.   else { var done = 0; }
  8.   if (done) {
  9.    c.direction[i] = random(2);
  10.    c.speed2[i] = c.speed + random(4);
  11.    var newX = getViewXOffset() + c.direction[i] * (getViewWidth() - c.imageWidth)
  12.    var newY = getViewYOffset() + random(getViewHeight() - c.imageHeight)
  13.   }
  14.   moveLayer(c.prefix + i, newX, newY);
  15.  }
  16.  setTimeout("updateScurry(c" + c.uid + ")", c.updateDelay);
  17. }

Raw Paste

Login or Register to edit or fork this paste. It's free.