xxxxxxxxxx
56
let tableau_x = [];
let tableau_y = [];
let taille_largueur = [];
let taille_hauteur = []
let nb;
let couleurs = [];
function setup() {
createCanvas(800, 800);
background(0);
nb = 10;
for (let i = 0; i < nb; i++){
tableau_x[i] = random(20, 800);
tableau_y[i] = random(20, 800);
taille_largueur[i] = random(20,70);
taille_hauteur[i] = random(20,70);
couleurs[i] = "black";
}
}
function draw() {
background(0);
if (mouseIsPressed){
for (let i = 0; i < nb; i++){
couleurs[i] = color(random(0, 255),random(0, 255),random(0, 255));
}
}
if (keyIsPressed && keyCode==13){
for (let i = 0; i < nb; i++){
tableau_y[i] -= 2;
}
}
for (let i = 0; i < nb; i++){
drawFantome(tableau_x[i], tableau_y[i], taille_largueur[i], taille_hauteur[i], couleurs[i]);
}
}
function drawFantome(a, b, c, d, e){
noStroke();
fill(255);
triangle(a-c/2, b, a+c/2, b, a, b+70);
ellipse(a, b, c, d);
fill(e);
ellipse(a-7, b, 10, 10);
ellipse(a+7, b, 10, 10);
fill(0);
ellipse(a, b+7, 4, 7);
}