Maithé Escobar - Objeto

De Casiopea
Maithé Escobar - Tarea 6


TítuloMaithé Escobar - Tarea 6
Tipo de ProyectoProyecto de Curso
Palabras Clavetarea 6
Período2012-
Del CursoImagen Escrita 2012,
CarrerasDiseño Gráfico"Diseño Gráfico" is not in the list (Arquitectura, Diseño, Magíster, Otra) of allowed values for the "Carreras Relacionadas" property., 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)Maithé Escobar
ProfesorHerbert Spencer

Elemento[] cosas; int count;

Elemento especial;

void setup() {

cosas = new Elemento[50]; count = 0; size(700, 700); background(56); especial = new Elemento(width/1000, height/100); especial.c = color(#05EDE7, 5); especial.d = -5; 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(987, 201, 980, 677);
 velx = vely = 0;
 edadMax = round(random(100, 200));
 edad = 0;
 d = random(-20, 90);

} Elemento() {

 x = random(width);
 y = random(height);
 c = color(0,78,987,600);
 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 *= -1;
   vely += random(-1, 1);
   
 }
 if ((y < d/2) || (y > height - (d/2))) {
   vely *= 0;
   velx += random(0, 5);
   
 }

}

void existe() {

 if (edad < edadMax) {
   dibuja();
   actualizaPosicion();
   revisaSiRebota();
 }

} }