Must be something obvious but I can't get it. Perhaps the original code is too old. There it is : // TearDropsFondUni //perlin vertic1 demarre le 22/3/2012 // révisions de fevrier 2013 // ajout de musique novembre 2017 // version ok maintenant je peux travailler le fond et les couleurs // essai avec couleurs // nouveau 2017 import ddf.minim.* ; Minim minim ; AudioPlayer player;
ArrayList perl1; PImage img; boolean bStop; String titre = ("TearDropsFondUni"); String site =("www.efrinumeric.com"); //Perlin p[]; Drop d; float var_y = 10.0; float var_x = 10.0; float val_id = 0.08 ;// bcp mieux que . int s_min = 1 ;// interessant avant 2 et 5 int s_max = 3 ;// ca accelere vachement int strookW = 3;// interessant avant javais 2 avec 6 c encore otre chos float surface; //int diam; int imgWidth, imgHeight; float yPos, xPos; boolean hit = false; //int nbMax = 33000; int nbMax = 32000;
void setup() { size(displayWidth, displayHeight); //size(1400, 600); smooth(); //surface = height/4; imgWidth = width/90 ; imgHeight= height/40 ; noCursor(); colorMode(RGB); img = loadImage("GoutteBlanche.png"); //diam=img(height); d = new Drop(); perl1 = new ArrayList(); // la suite pour la musique minim = new Minim(this); player = minim.loadFile("NOTRE DAME E.WAV"); //player.play(); }
void draw() { noStroke(); fill(#193AAF, 80); rect(0, 0, width, height); strokeWeight(strookW); stroke(255, 60); fill(255); text(site, 10, (height-10)); text(titre, (width-textWidth(titre)-15), (height-10)); d.run(); d.display(); d.gravity(); //for(int i=0; i<p.length; i++) p[i].update();//render particles if (hit) { createPerlin(xPos); if (perl1.size()>nbMax) { supprime(); } } for (int i=0; i<perl1.size(); i++) { Perl1 p = (Perl1) perl1.get(i); p.update(); } }
void createPerlin(float _xPos) { this.xPos=_xPos; for (int i=0;i<(200); i++) { perl1.add(new Perl1(i/random(1000, 200), this.xPos, surface)); } }
void supprime() { int nbDiff = perl1.size()-nbMax; for (int i=nbDiff;i>=0;i--) { perl1.remove(i); } } void stop() { minim.stop(); super.stop(); } //========================================================================== class Perl1 { float id, x, y, xp, yp, s, d;
//public Perl1(float _id, float _xPos, float _y) { public Perl1(float _id, float xPos, float _y) { id=_id; y=yp=_y; x=xp=xPos; s=random(s_min, s_max); }
void update() { //if (var_x<(width-20)) { if (var_y<(height-10)) { var_y += noise(-0.01, +0.01); } else { //var_x = random(100,width/2) ; var_y = 1;//ici avant javais 0=je supprime } //var_x += noise(-0.2,+0.2); id+=val_id; d=(noise(id, y/var_x, x/var_x)-0.5)var_y; y+=cos(radians(d))s; x+=sin(radians(d))*s+random(1);
if (y<height) {
fill(strookW);
stroke(255);
line(xp, yp, x, y);// le +2 c nouveau
}
xp=x;
yp=y;
if (hit) {
xPos=x;
hit=false;
}
} }
//================================================== class Drop { float x; float y; float yspeed; float dSurface;
Drop() { y = 0; yspeed = random(-0.1, 0.1); x = random(10, width-10); dSurface = random(height.2,height.8);
}
void run() { if (y<dSurface-(imgHeight2)) { y += yspeed; } else { xPos =x; hit = true ; y=0; x=random(10, width-10); yspeed=random(0.5); //surface--; surface = dSurface ; dSurface = random(height.2,height*.8); } }
void gravity() { //yspeed += 0.05; yspeed += 0.05; }
void display() { stroke(0); // Displays the image at its actual size at point (0,0) image(img, x, y, imgWidth, imgHeight); } }
void keyPressed() { if ( player.isPlaying() ) { player.pause(); } // if the player is at the end of the file, // we have to rewind it before telling it to play again else if ( player.position() == player.length() ) { player.rewind(); player.play(); } else { player.play(); } }
Thanks in advance.