Oriel Badillo - Imagen Escrita 2012, tarea 6
De Casiopea
Título | Oriel Badillo - Tarea 6, objero |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tarea 6 |
Período | 2012- |
Asignatura | Taller Inicial Común 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Oriel Badillo |
Profesor | Herbert Spencer |
Elemento[] cosas; int count;
Elemento especial;
void setup() {
cosas = new Elemento[100]; count = 0; size(400, 400); background(#ECED05); especial = new Elemento(width/1000, height/100); especial.c = color(#05EDE7, 5); especial.d = -3; especial.velx = 10;
}
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(174, 201, 224, 30); velx = vely = 0; edadMax = round(random(100, 200)); edad = 0; d = random(-1, 9); }
Elemento() { x = random(width); y= random(height); c = color(0,100,20,20); velx = vely = 3; edadMax = round(random(100, 200)); edad = 0; d = random(2, -2); }
void dibuja() { noStroke(); fill(c); ellipse(x, y, d, d); edad ++; d -= 3; }
void actualizaPosicion() { x += velx; y += vely; }
void revisaSiRebota() { if ((x < d/2) || (x > width - (d/2))) { velx *= -2; vely += random(-1, 2); }
if ((y < d/2) || (y > height - (d/2))) { vely *= 0; velx += random(0, 5); } }
void existe() { if (edad < edadMax) { dibuja(); actualizaPosicion(); revisaSiRebota(); }
}
}