//declaracion de variables
float posX[];
float posY[];
int matados[];
float angulos[];
int numrect = 500;
int puntaje = 0;
PFont miletrica;
//setup o configuracion
void setup() {
size(400,400,P3D);
background(255);
noStroke();
posX = new float[numrect];
posY = new float[numrect];
angulos = new float[numrect];
matados = new int[numrect];
for(int i=0;i<numrect;i = i+1) {
posX[i] = random(380);
posY[i] = random(30);
matados[i] = 0;
angulos[i] = 0;
}
//miletrica = loadfont("Univers45.vlw");
//textFont(miletrica, 18);
}
//loop
void draw(){
puntaje = 0;
background(225);
for(int i=0;i<numrect; i = i+1){
posY[i] = posY[i] + random(0.01*i);
angulos[i] = angulos[i] + random(0.001*i);
}
//funciones
for(int i=0; i<numrect;i =i+1){
if(matados[i] ==0){
pushMatrix();
translate(posX[i],posY[i]);
rotate(angulos[i]);
if(dist(mouseX, mouseY, posX[i], posY[i])<20){
fill(230,0,130,150);
matados[i] = 1;
rect(0,0,20,20);
}
else{
fill(170+random(-60,60),130+random(-80,80),0);
rect(0,0,10,10);
}
popMatrix();
}
}
for(int i=0;i<numrect; i = i+1){
puntaje = puntaje + matados[i];
}
println(puntaje);
fill(230,0,130);
text("el puntaje es" +puntaje,10,390); }
Ejemplos:
No hay comentarios:
Publicar un comentario