PImage b; // definit une variable image Ball1[] one; // definit un tableau "one" dont les element sont "Ball1" int num1 = 100; // definit une variable "num1" à la valeur 100 Ball2[] two; int num2 = 100; Ball3[] three; int num3 = 100; Ball4[] four; int num4 = 100; void setup(){ // parametres du sketch size (640,400); // taille definie à 640px x 400px background(0); // couleur noire de fond b = loadImage ("2009.png"); // charge l'image "2009.png" one = new Ball1[num1]; // charge autant de "one" que de "num1" for (int i=0; i 160) && (mouseX < 320)){ // autrement si la position verticale de la souris est supérieure à 160 et inférieure à 320 for (int i=0; i 320) && (mouseX < 480)){ for (int i=0; i 480){ for (int i=0; i width) || (xc < 0)){ // si "xc" est superieur à la largeur ou inferieur à 0 sx = -sx; // sx est egal à -sx } else if (yc < lim1) { // si "yc" est superieur à la variable "lim1" yc = 400; xc = 80; } else if (yc > 400){ sy = -sy; xc = 80; } } } class Ball2 { int xc2, yc2 ; int sx2, sy2 ; void move2() { sx2 = int (random(-12, 12)); sy2 = int (random(10)); xc2 += sx2 ; yc2 -= sy2 ; color c = b.get(xc2,yc2); if(c == #000000) { stroke (51) ; strokeWeight(2); } else if (c == #ffffff) { stroke (255) ; strokeWeight(2); } else if (c == #999999) { stroke (random(255),random(255),random(255)); strokeWeight(3); } float lim2 = mouseY - random(100); point (xc2, yc2); if ((xc2 > width) || (xc2 < 0)){ sx2 = -sx2; } else if (yc2 < lim2) { yc2 = 400; xc2 = 240; } else if (yc2 > height){ sy2 = -sy2; xc2 = 240; } } } class Ball3 { int xc3, yc3 ; int sx3, sy3 ; void move3() { sx3 = int (random(-12, 12));; sy3 = int (random(10)); xc3 += sx3 ; yc3 -= sy3 ; color c = b.get(xc3,yc3); if(c == #000000) { stroke (51) ; strokeWeight(2); } else if (c == #ffffff) { stroke (255) ; strokeWeight(2); } else if (c == #999999) { stroke (random(255),random(255),random(255)); strokeWeight(3); } float lim3 = mouseY - random(100); point (xc3, yc3); if ((xc3 > width) || (xc3 < 0)){ sx3 = -sx3; } else if (yc3 < lim3) { yc3 = 400; xc3 = 400; } else if (yc3 > height){ sy3 = -sy3; xc3 = 400; } } } class Ball4 { int xc4, yc4 ; int sx4, sy4 ; void move4() { sx4 = int (random(-12, 12)); sy4 = int (random(10)); xc4 += sx4 ; yc4 -= sy4 ; color c = b.get(xc4,yc4); if(c == #000000) { stroke (51) ; strokeWeight(2); } else if (c == #ffffff) { stroke (255) ; strokeWeight(2); } else if (c == #999999) { stroke (random(255),random(255),random(255)); strokeWeight(3); } float lim4 = mouseY - random(100); point (xc4, yc4); if ((xc4 > width) || (xc4 < 0)){ sx4 = -sx4; } else if (yc4 < lim4) { yc4 = 400; xc4 = 560; } else if (yc4 > height){ sy4 = -sy4; xc4 = 560; } } }