class particle { ////////////////////////////////////////////////////////////////// ////////////////// ATTRIBUTS float x, y, vx, vy; ////////////////////////////////////////////////////////////////// ////////////////// CONSTRUCTEUR particle(float X, float Y) { x = X; y = Y; vx = 0; vy = 0; } ////////////////////////////////////////////////////////////////// ////////////////// METHODES void show() { pushStyle(); noStroke(); fill(255,255,255,80); rect(x, y, 1,1); popStyle(); } ////////////////////////////////////////////////////////////////// void update(float[] u, float[] v, float dt) { int i = int(x/h); int j = int(y/h); int scale = N; //vx *= 0.999; //vy *= 0.999; vx = u[IX(i, j)]*scale; vy = v[IX(i, j)]*scale; if (i>1) { vx += u[IX(i-1, j)]*0.5*scale; vy += v[IX(i-1, j)]*0.5*scale; } if (i1) { vx += u[IX(i, j-1)]*0.5*scale; vy += v[IX(i, j-1)]*0.5*scale; } x += vx*dt; y += vy*dt; if (x<0 || x>width || y<0 || y>height) { x = random(0, width); y = random(0, height); } show(); } ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// }