Javiera Godoy Tarea 6

De Casiopea
Javiera Godoy Tarea 6


TítuloJaviera Godoy Tarea 6
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 6
Período2012-
AsignaturaTaller Inicial 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasArquitectura
Alumno(s)Javiera Godoy
ProfesorHerbert Spencer

Elemento[] cosas; int count;

Elemento especial;

void setup() {

cosas = new Elemento[1000];
count = 0;
size(700, 700);
background(#000000);
especial = new Elemento(width/1000, height/100);
especial.c = color(#DBDAD4, 50);
especial.d = -3;
especial.velx = 49;

}

void draw() {

for (int i = 0; i < count; i++) {
  cosas[i].existe();
}
especial.existe();

}


void mousePressed() {

cosas[count] = new Elemento(mouseX, mouseY);
cosas[count].velx = mouseX - pmouseX;
cosas[count].vely = mouseY - pmouseY;
count ++;

}

void keyPressed() {

cosas[count] = new Elemento();
cosas[count].velx = mouseX - pmouseX;
cosas[count].vely = mouseY - pmouseY;
count ++;

}

/*--------------------------------------------------------------*/

class Elemento {

float x, y; // posición
float d; // diámtero
color c; 
float velx, vely; // velocidad
int edadMax;
int edad; 
Elemento(float posX, float posY) {
  x = posX;
  y = posY;
  c = color(#35B486, 50);
  velx = vely = 0;
  edadMax = round(random(10000, 10000));
  edad = 0;
  d = random(-1, x);
}
Elemento() {
  x = random(width);
  y = random(height);
  c = color(255);
  velx = vely = 10;
  edadMax = round(random(100, 10000));
  edad = 5;
  d = random(x, -2);
}
void dibuja() {
  noStroke();
  fill(c);
  ellipse(x, y, d, d);
  edad ++;
  d -= 2;
}
void actualizaPosicion() {
  x += velx;
  y += vely;
}
void revisaSiRebota() {
  if ((x < d/2) || (x > width - (d))) {
    velx *= 0;
    vely += random(-1, 1);
  }
  if ((y < d) || (y > height - (d/2))) {
    vely *= 0;
    velx += random(0, 5);
  }
}
void existe() {
  if (edad < edadMax) {
    dibuja();
    actualizaPosicion();
    revisaSiRebota();
  }

} }