int zone=300; float force=2; float retour=0.001; int amplitude=15; int j=0; float oldY=zone/2; float jaune; float fps=0; float frame=0; float t=second(); float[] ligne = new float[zone]; //Ball[] listBall = new Ball[999]; Ball b1 = new Ball(zone/4, 0); Ball b2 = new Ball((zone/4)*2, 0); Ball b3 = new Ball((zone/4)*3, 0); void setup(){ size(zone,zone); //framerate(60); smooth(); cursor(CROSS); //PFont font; //font = loadFont("data/ArialMT-14.vlw"); //textFont(font, 14); //textAlign(RIGHT); for(int i=0; i zone/2){ligne[i] -= retour*(ligne[i]-(zone/2));} if(ligne[i] < zone/2){ligne[i] += retour*((zone/2)-ligne[i]);} ligne[i]=((ligne[i]) + ligne[i-1] + ligne[i+1])/3; j++; if(j==amplitude && i<(zone-amplitude+1)){ j=0; curveVertex(i, ligne[i]); } jaune = 5*((zone/2)-ligne[i]); if(jaune<0){jaune=jaune*-1;} stroke(255,jaune,0); point(i,ligne[i]); } curveVertex(zone-1, zone/2); curveVertex(zone-1, zone/2); stroke(255); strokeWeight(2); endShape(); if(mousePressed == true){oldY = mouseY;} b1.update(ligne[b1.getXpos()]); b2.update(ligne[b2.getXpos()]); b3.update(ligne[b3.getXpos()]); } void mouseDragged(){ if(mouseX0 && mouseY>0){ ligne[mouseX] -= (oldY-mouseY)*force; oldY = mouseY; } } class Ball { float Xpos, Ypos, Yec; Ball(float a, float b){ Xpos=a; Ypos=b; Yec=0; } void update(float ground) { if(Ypos <= ground-10){ Ypos += Yec; Yec += 0.01; }else{ Ypos = ground-10; Yec = (Yec*-1)+.2; Ypos += Yec; } fill(255); ellipse(Xpos, Ypos, 10, 10); } int getXpos(){ return int(Xpos); } }