/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://dflab.sketchpad.cc/sp/pad/view/ro.spdAAk2nfPA/rev.39
*
* authors:
* Daniela Calças
* 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, "Marta Gomes - 02", created by Marta Gomes
// http://dflab.sketchpad.cc/sp/pad/view/ro.9bEvp0npSwXljW/rev.122
// 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
/* @pjs preload="/static/uploaded_resources/p.10117/P4060226.png"; */
float px[];
float py[];
int prey = 40;
PImage prey1;
PImage hunt;
void setup() {
size(500, 375);
arvore = loadImage("/static/uploaded_resources/p.10117/P4060226.png");
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 (arvore, 0, 0, 500, 375);
for (int i = 0; i < prey; i = i+1) {
px[i] = constrain (px[i] + random (-1, 1), 0, width);
py[i] = constrain (py[i] + random (-1, 1), 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));
}