double dist, dire; point p[] = new point[100]; int hpx[] = new int[p.length]; int hpy[] = new int[p.length]; double colH, colS, colB; Color col; point wh[] = new point[p.length]; int sec; int current; int chase; int xx, yy; boolean mouseP; //sample [setup, 600, 600]{ xx = 30; yy = 30; for(int i = 0; i < p.length; i ++){ if(monitorWidth < xx){ yy += 60; xx = 30; } hpx[i] = xx; hpy[i] = yy; p[i] = point(monitorWidth/2, monitorHeight/2); xx += 60; wh[i] = point(0, 0); } sec = 0; current = 0; chase = 0; mouseP = false; colH = 0.0; colS = 1.0; colB = 1.0; setBackColor(255, 255, 30); } [paint]{ clearAll(); for(int i = 0; i < current; i++){ col = Color.getHSBColor((float)colH, (float)colS, (float)colB); setColor(col); fillRect(p[i].x - wh[i].x/2., p[i].y - wh[i].y/2., wh[i].x, wh[i].y); } } [interval, 0, 0.5]{ if(current < p.length){ current += 1; } } [interval, 1, 0.5]{ if(sec < p.length){ sec += 1; } } [interval, 32, 0.2]{ if(chase < p.length){ chase += 1; } } [interval, 1, 1]{ for(int i = chase; i < current; i ++){ dist = wh[i].distanceTo(0, 0); dire = wh[i].directionTo(0, 0); wh[i].push(dist*2., dire); } } [always]{ for(int i = chase; i < current; i ++){ if(i < sec){ dist = p[i].distanceTo(hpx[i], hpy[i]); dire = p[i].directionTo(hpx[i], hpy[i]); p[i].push(dist / 10., dire); } dist = wh[i].distanceTo(60, 60); dire = wh[i].directionTo(60, 60); wh[i].push(dist/10., dire); } for(int i = 0; i < current; i ++){ dist = wh[i].distanceTo(60, 60); dire = wh[i].directionTo(60, 60); wh[i].push(dist/10., dire); } if(mouseP == true){ for(int i = 0; i < chase; i ++){ dist = p[i].distanceTo(hpx[i], hpy[i]); dire = p[i].directionTo(hpx[i], hpy[i]); p[i].push(dist/2., dire); } }else{ for(int i = 0; i < chase; i ++){ dist = p[i].distanceTo(mouse); dire = p[i].directionTo(mouse); p[i].push(dist/2., dire); } } } [mousePressed]{ mouseP = true; } [mouseReleased]{ mouseP = false; }