Alexandra Staig tarea 6
De Casiopea
Título | Alexandra Staig |
---|---|
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 | Diseño Gráfico, Diseño Industrial |
Alumno(s) | Alexandra Staig |
Profesor | Herbert Spencer |
<nowiki>Basado en el ejemplo de Luciano Morales. Elemento[] cosas; int count; Elemento especial; void setup() { cosas = new Elemento[200]; count = 0; size(700, 700); background(255); especial = new Elemento(width/5, height/15); especial.c = color(#308BCE, #308BCE); especial.d = 20; especial.velx = 15; especial.vely = 100 ; especial.edadMax = 200; } 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 = mouseX - pmouseY; count ++; } void keyPressed() { cosas[count] = new Elemento(); 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(#08298A, #084B8A, #DF7401, #B40404); velx = vely = 0; edadMax = round(random(300, 10)); edad = 0; d = random(16, 2); } Elemento() { x = random(width); y = random(height); c = color(#08298A, 100, 100, 20); velx = vely = 0; edadMax = round(random(100, 20)); edad = 0; d = random(2, 30); } void dibuja() { noStroke(); fill(c); ellipse(x,y, 50, 80); edad ++; d -= 50; } void actualizaPosicion() { x += velx; y += vely; } void revisaSiRebota() { if ((x < d/80) || (x > width - (d/80))) { velx *= -1; vely += random(-1, 1); } if ((y < d/30) || (y > height - (d/30))) { vely *= -1; velx += random(-5, 5); } } void existe() { if (edad < edadMax) { dibuja(); actualizaPosicion(); revisaSiRebota(); } } } </nowiki>