Favio Matus tarea 6
Título | Tarea 6 |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 6, Favio Matus |
Del Curso | Imagen Escrita 2012, |
Carreras | 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) | Favio Matus |
Profesor | Herbert Spencer |
Elemento[] cosas; int count;
Elemento especial;
void setup() { cosas = new Elemento[100]; count = 0; size(700, 700); background( 0); especial = new Elemento((width^2)/2, height/2); especial.c = color(#FF0033, #CCFF33); especial.d = 40; especial.velx = 50; especial.vely = 30; especial.edadMax = 1000; }
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+10; 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(#9933CC, #9933CC, #9933CC, #9933CC); velx = vely = 0; edadMax = round(random(100, 200)); edad = 0; d = random(5, 15); }
Elemento() { x = random(height); y = random(width); c = color(#9933CC, #9933CC, #9933CC, #9933CC); velx = vely = 0; edadMax = round(random(2, 300)); edad = 0; d = random(20, 50); }
void dibuja() { noStroke(); fill(c); rect(y, x+2, d+20, d); edad ++; d -= 0.1; }
void actualizaPosicion() { x += velx; y += vely; }
void revisaSiRebota() { if ((x < d) || (x > height - d)) { velx *= -1; vely += random(-1, 5); }
if ((y < d/2) || (y > height - (d/2))) { vely *= -1; velx += random(-3, 3); } }
void existe() { if (edad < edadMax) { dibuja(); actualizaPosicion(); revisaSiRebota(); } } }