/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://dflab.sketchpad.cc/sp/pad/view/ro.IrRHEwFBFWM/rev.122
*
* authors:
* Marta Gomes
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "09 - Interacção", created by Pedro Ângelo
// http://dflab.sketchpad.cc/sp/pad/view/ro.9oKynkx5tfBnv3/rev.158
float px[];
float py[];
int prey = 15;
PImage prey1;
PImage hunt;
void setup() {
size(500, 500);
cidade = loadImage("/static/uploaded_resources/p.10286/city.jpg");
prey1 = loadImage("/static/uploaded_resources/p.10286/prey.png");
hunt = loadImage("/static/uploaded_resources/p.10286/hunt.png");
px = new float[prey];
py = new float[prey];
for (int i = 0; i < prey; i++) {
px[i] = random (width);
py[i] = random (height);
}
}
void draw() {
image (cidade, 0, 0, 500, 600);
for (int i = 0; i < prey; i = i+1) {
px[i] = constrain (px[i] + random (-2, 2), 0, width);
py[i] = constrain (py[i] + random (-2, 2), 0, height);
if (dist (px[i], py[i], mouseX, mouseY) < 100) {
vx = (px[i] - mouseX);
vy = (py[i] - mouseY);
px[i] = px[i] + vx;
py[i] = py[i] + vy;
}
image (prey1, px[i], py[i]);
}
image (hunt, (mouseX - 60), (mouseY - 68));
}