Consuelo Miranda tarea 6
De Casiopea
Título | Tarea 6 |
---|---|
Palabras Clave | tarea 6 |
Período | 2012- |
Asignatura | Taller Inicial 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Consuelo Miranda |
Profesor | Herbert Spencer |
Elemento[] cosas; int count; Elemento especial; void setup() { cosas = new Elemento[10]; count = 0; size(700, 700); background(0); especial = new Elemento(width/1000, height/10); especial.c = color(250, 1); especial.d = -7; especial.velx = 100; } 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(176, 203, 222, 34); velx = vely = 0; edadMax = round(random(100, 200)); edad = 0; d = random(-3, 1); } Elemento() { x = random(width); y= random(height); c = color(0,200,200,10); velx = vely = 5; edadMax = round(random(200, 100)); edad = 0; d = random(1, -1); } void dibuja() { noStroke(); fill(c); ellipse(x, y, d, d); edad ++; d -= 3; } void actualizaPosicion() { x += velx; y += vely; } void revisaSiRebota() { if ((x < d/6) || (x > width - (d/9))) { velx *= -6; vely += random(-1, 6); } if ((y < d/4) || (y > height - (d/8))) { vely *= 0; velx += random(0, 4); } } void existe() { if (edad < edadMax) { dibuja(); actualizaPosicion(); revisaSiRebota(); } } }