Daniela Valenzuela: pizarra 2.0
De Casiopea
Título | pizarra de cuadrados |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Palabras Clave | tareas 6 |
Período | 2012- |
Asignatura | Imagen Escrita 2012, Taller Inicial 1ª y 2ª Etapa, Taller Inicial Común 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita 2012, |
Carreras | Arquitectura |
Alumno(s) | Daniela Valenzuela |
Profesor | Herbert Spencer |
// basado en archivo Spencer
danielement [] cubo; int count; void setup() { cubo = new danielement [100]; count = 0; size(screen.width, screen.height); background(200); } void draw() { for (int i = 0; i < count; i++) { cubo[i].existe(); } } void mousePressed() { cubo[count] = new danielement (mouseX, mouseY); cubo[count].velx = mouseX - pmouseX; cubo[count].vely = mouseY - pmouseY; count ++; } void keyPressed() { cubo[count] = new danielement (); count ++; } // other page class danielement { float x, y; // posición float d; // diámtero color c; float velx, vely; // velocidad int edadMax; int edad; danielement (float posX, float posY) { x = posX; y = posY; c = color(37, 30); velx = vely = 0; edadMax = round(random(100, 200)); edad = 0; d = random(2, 30); } danielement () { x = random(width); y = random(height); c = color(255, 100, 100, 20); velx = vely = 0; edadMax = round(random(100, 200)); edad = 0; d = random(2, 30); } void dibuja() { noStroke(); fill(c); rect(x, y, d, d); 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/2))) { vely *= -1; velx += random(-1, 1); } } void existe() { if (edad < edadMax) { dibuja(); actualizaPosicion(); revisaSiRebota(); } } }