Saltar al contenido Saltar a la navegación

Tarea Pelotas

Pelotas



TítuloPelotas
Tipo de ProyectoProyecto de Curso
AsignaturaTaller Inicial Común 1ª y 2ª Etapa,
Del CursoImagen Escrita,
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)Cindy Sanhueza
ProfesorHerbert Spencer

int nClicks; Pelota[] P = new Pelota[100]; void setup() {

 size(300, 300);
 ellipseMode(CENTER);
 smooth();
 nClicks = 0; 
 background(#EDE27C);
 fill (104, 198, 50, 200);
 stroke(255, 100);

}

void draw() {

 for (int i = 0; i < nClicks; i++) {
   P[i].render();
 }

}

void mouseReleased() {

 P[nClicks] = new Pelota(mouseX, mouseY, pmouseX, pmouseY);
 nClicks++;
 if (nClicks == 100) { 
   nClicks = 0;
 }

}

class Pelota {

 float x, y, velX, velY, r, masa;
 Pelota(float _x, float _y, float _px, float _py) {
   x = _x;
   y = _y;
   velX = (x - _px)+ random (-5, 10);
   velY = (y - _py)+ random (-8, 6);
   r = random(2, 12);
 }
 void render() {
   x += velX;
   y += velY;
   if ((x < r) || (x > width - r)) {
     velX =2 - velX;
   }  
   if ((y > r) || (y > height - r)) {
     velY = 3 - velY;
   }
   ellipse(x, y, 2*r, 2*r);
 }

}