Le pareti sono chiuse e le scintille rimbalzano…
- Mouse (tasto): accende il fuoco
- Applicazione Java
int num=300; float raggio0; Artificio[] Arte=new Artificio[num]; void setup() { size(500, 500); frameRate(30); raggio0=width*0.01; } void draw() { background(0); for(int i=0; i < num; i++) { if(Arte[i] != null) Arte[i]=Arte[i].move(); if(Arte[i] != null) Arte[i].draw(); } } void mousePressed() { inizia(); } void inizia() { for(int i=0; i < num; i++) Arte[i]=new Artificio(); } class Artificio { float xpos, ypos, velX, velY, colore; Artificio() { xpos=mouseX; ypos=mouseY; float angolo=random(TWO_PI); float raggio=random(raggio0); velX=raggio*cos(angolo); velY=raggio*sin(angolo); colore=color(205+random(50), 205+random(50), 0); } void draw() { set(int(xpos), int(ypos), int(colore)); } Artificio move() { xpos+=velX; ypos+=velY; if(xpos < 0) { xpos*=-1; velX*=-1; } else if(xpos >= width) { xpos-=(xpos-width); velX*=-1; } else if(ypos <= 0) { ypos*=-1; velY*=-1; } else if(ypos > height) return null; velY+=0.1; return this; } }