Pelotas
De Casiopea
Título | Pelotas y distancia |
---|---|
Tipo de Proyecto | Proyecto de Taller |
Período | 2011-2011 |
Asignatura | Imagen Escrita, |
Del Curso | Imagen Escrita, |
Carreras | Arquitectura |
Alumno(s) | Trajan Pirkovic |
Profesor | Herbert 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); }
}