Matias Chacon: rebote petardo

De Casiopea
Revisión del 09:46 3 may 2012 de Raanbr (discusión | contribs.) (Página creada con '{{Proyecto |Título=matias Chacon tarea 6 |Palabras Clave=tarea 6, |Carreras Relacionadas=Diseño Gráfico, Diseño Industrial |Asignaturas Relacionadas=Taller Inicial Común 1...')
(difs.) ← Revisión anterior | Revisión actual (difs.) | Revisión siguiente → (difs.)


Títulomatias Chacon tarea 6
Palabras Clavetarea 6
AsignaturaTaller Inicial Común 1ª y 2ª Etapa,
Del CursoImagen Escrita 2012,
CarrerasDiseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property., Diseño Industrial"Diseño Industrial" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property.
Alumno(s)Matias Chacon
ProfesorHerbert Spencer

Elemento[] cosas; int count;

Elemento especial;

void setup() {

cosas = new Elemento[780];
count = 0;
size(900, 900);
background(#FF00BF);
especial = new Elemento(width/3, height/5);
especial.c = color(#2EFEC8);
especial.d = 8;
especial.velx = 100;
especial.vely = 20;
especial.edadMax = 4500;

}

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();
count ++;

}

class Elemento {

float x, y;
float d;
color c; 
float velx, vely;
int edadMax;
int edad; 
Elemento(float posX, float posY) {
  x = posX;
  y = posY;
  c = color(240);
  velx = vely = 0;
  edadMax = round(random(1000, 200));
  edad = 0;
  d = random(14, 15);
}
Elemento() {
  x = random(width);
  y = random(height);
  c = color(81, 250, 240);
  velx = vely = 0;
  edadMax = round(random(1000, 200));
  edad = 0;
  d = random(14, 15);
}
void dibuja() {
  noStroke();
  fill(c);
  ellipse(x, y, 10, d+10);
  edad ++;
  d -= 0.1;
}
void actualizaPosicion() {
  x += velx;
  y += vely;
}
void revisaSiRebota() {
  if ((x < d/2) || (x > width - (d/2))) {
    velx *= -1;
    vely += random(-1, 1);
  }
  if ((y < d/2) || (y > height - d)) {
    vely *= -1;
    velx += random(-1, 1);
  }
}
void existe() {
  if (edad < edadMax) {
    dibuja();
    actualizaPosicion();
    revisaSiRebota();
  }
}

}