Daniela Araya Vargas: Pelotas
De Casiopea
Título | Daniela Araya Vargas: Pelotas |
---|---|
Tipo de Proyecto | Proyecto de Curso |
Asignatura | Taller Inicial 1ª y 2ª Etapa, |
Del Curso | Imagen Escrita, |
Carreras | Arquitectura |
Alumno(s) | Daniela Araya Vargas |
Profesor | Herbert Spencer |
int nClicks; // contador de clicks Pelota[] P = new Pelota[100]; // arreglo 'P' de 100 Pelotas Pelota[] P = new Pelota[150]; // arreglo 'P' de 100 Pelotas void setup() { size(600, 600); background(208, 231, 234); ellipseMode(CENTER); smooth(); nClicks = 0; // reseteo el contador a 0 fill(255, 249, 59); stroke(0, 80); } 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 == 30) { nClicks = 1; } } //--------------------------- 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 (-3, 2); velY = (y - _py)+ random (-2, - 2); r = random(1, 25); } 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, 3*r, 5*r); endRecord(); } }