xxxxxxxxxx
//variabili
let posx,posy // posizione
let sX=15, sY=15 // velocitá
let t=0, tff=0.33; // tempo
function setup(){
wH =windowHeight;
wW = windowWidth;
createCanvas(wW, wH);
background('#00c2f9');
posx=windowHeight/2;
posy=windowWidth/2;
}
function draw(){
background('#00c2f9');
fill(52, 164, 235);
bird(posx,posy)
textSize(20);
text("valore del tempo="+t, 15, 25);
switch(true){
case ((posx-1900)>wW):posx=0; break;
case ((posy-1200)>wH):posy=0; break;
}
posx = posx + sX*tff;
posy = posy + sY*tff;
t = t + tff
}
function bird(x,y) {
fill(0);
rect(x / 2, y / 2, 40, 10); //1 riga pixel
rect(x / 2 - 20, y / 2 - 10, 110, 10);
stroke('#e0a800');
fill('#e0a800'); //2 riga pixel
rect(x / 2, y / 2 - 10, 40, 10);
stroke(0);
fill(0);
rect(x / 2 - 30, y / 2 - 20, 120, 10);
stroke('#e0a800');
fill('#e0a800');
rect(x / 2 - 20, y / 2 - 20, 50, 10); //3 riga pizel
stroke('#ff6a00');
fill('#ff6a00');
rect(x / 2 + 40, y / 2 - 20, 40, 10);
stroke(0);
fill(0);
rect(x / 2 - 50, y / 2 - 30, 140, 10);
stroke('#e0a800');
fill('#e0a800');
rect(x / 2 - 20, y / 2 - 30, 40, 10); //4 riga pixel
stroke('#ff6a00');
fill('#ff6a00');
rect(x / 2 + 30, y / 2 - 30, 10, 10);
stroke(0);
fill(0);
rect(x / 2 - 60, y / 2 - 40, 160, 10);
stroke('#ffd800');
fill('#ffd800');
rect(x / 2 - 50, y / 2 - 40, 30, 10);
rect(x / 2 - 10, y / 2 - 40, 40, 10); //5 riga pixel
stroke('#ff6a00');
fill('#ff6a00');
rect(x / 2 + 40, y / 2 - 40, 50, 10);
stroke(0);
fill(0);
rect(x / 2 - 70, y / 2 - 50, 160, 10);
stroke('#ffd800');
fill('#ffd800');
rect(x / 2 - 60, y / 2 - 50, 10, 10);
rect(x / 2, y / 2 - 50, 40, 10); //6 riga pixel
rect(x / 2 - 20, y / 2 - 50, 10, 10);
stroke(255);
fill(255);
rect(x / 2 - 50, y / 2 - 50, 30, 10);
stroke(0);
fill(0);
rect(x / 2 - 70, y / 2 - 60, 150, 10);
stroke(255);
fill(255);
rect(x / 2 - 60, y / 2 - 60, 50, 10); //7 riga pixel
rect(x / 2 + 40, y / 2 - 60, 30, 10);
stroke('#ffd800');
fill('#ffd800');
rect(x / 2, y / 2 - 60, 30, 10);
stroke(0);
fill(0);
rect(x / 2 - 70, y / 2 - 70, 150, 10);
stroke(255);
fill(255);
rect(x / 2 - 60, y / 2 - 70, 40, 10); //8 riga pixel
rect(x / 2 + 30, y / 2 - 70, 40, 10);
stroke('#ffd800');
fill('#ffd800');
rect(x / 2 - 10, y / 2 - 70, 30, 10);
stroke(0);
fill(0);
rect(x / 2 + 50, y / 2 - 70, 10, 10);
rect(x / 2 - 60, y / 2 - 80, 140, 10);
stroke(255);
fill(255);
rect(x / 2 + 30, y / 2 - 80, 40, 10); //8 riga pixel
stroke('#ffd800');
fill('#ffd800');
rect(x / 2 - 20, y / 2 - 80, 40, 10);
stroke(0);
fill(0);
rect(x / 2 + 50, y / 2 - 80, 10, 10);
rect(x / 2 - 40, y / 2 - 90, 110, 10);
stroke(255);
fill(255);
rect(x / 2 + 30, y / 2 - 90, 30, 10); //9 riga pixel
stroke('#ffd800');
fill('#ffd800');
rect(x / 2 - 30, y / 2 - 90, 50, 10);
stroke(0);
fill(0);
rect(x / 2 - 30, y / 2 - 100, 90, 10);
stroke(255);
fill(255);
rect(x / 2 + 40, y / 2 - 100, 10, 10); //10 riga pixel
stroke('#ffd800');
fill('#ffd800');
rect(x / 2 - 10, y / 2 - 100, 40, 10);
stroke(0);
fill(0);
rect(x / 2 - 10, y / 2 - 110, 60, 10); //11 riga pixel
}