Pelotas

De Casiopea
Pelotas y distancia


TítuloPelotas y distancia
Tipo de ProyectoProyecto de Taller
Período2011-2011
AsignaturaImagen Escrita,
Del CursoImagen Escrita,
CarrerasArquitectura
Alumno(s)Trajan Pirkovic
ProfesorHerbert Spencer


int nClicks; Pelota[] P = new Pelota[150];

void setup(){

 size(screen.width, 300);
 ellipseMode(CENTER);
 smooth();
 nClicks = 0; 
 fill(random(0,40),random(90,160),random(140, 255), random(10, 40));
 stroke(0, 50);
 

}

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 == 150){ 
   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 (-2, 5);
   velY = (y - _py)+ random (-2, 2);
   r = random(20,21);   
 }
 void render(){
   x += velX;
   y += velY;
   if ((x < r) || (x > width - r)){
     velX = 0 - velX;
   }  
   if ((y < r) || (y > height - r)){
     velY = 0 - velY;
   }
   ellipse(x,y, 2*r, 2*r);
 }

}