/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://playgramming.sketchpad.cc/sp/pad/view/ro.fWiWIib9HDi/rev.619
*
* authors:
* Justin Rodgers
* Devon Scott-Tunkin
*
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/* @pjs preload="/static/uploaded_resources/p.9748/Paper-Luigi-luigi-5320681-806-1024.png"; */
PImage img = loadImage("/static/uploaded_resources/p.9748/Paper-Luigi-luigi-5320681-806-1024.png");
int cx1 = 300;
int cy1 = 300;
int cradius1 = 100;
int cx2 = 300;
int cy2 = 200;
int cradius2 = 50;
int cx3 = 400;
int cy3 = 300;
int cradius3 = 100;
int cx4 = 20;
int cy4 = 200;
int cradius4 = 50;
int rx1 = 10;
int ry1 = 10;
int rwidth1 = 100;
int rx2 = 100;
int ry2 = 100;
int rwidth2 = 200;
int rx3 = 300;
int ry3 = 400;
int rwidth3 = 100;
int rx4 = 200;
int ry4 = 400;
int rwidth4 = 300;
int imagex = 200;
int imagey = 320;
int imagewidth = 100;
int imageheight = 100;
void setup() { // this is run once.
size(500, 500);
}
void draw() { // this is run repeatedly.
background(255);
cy1 = cy1 + 1;
cy2 = cy2 + 2;
cy3 = cy3 + 1;
cy4 = cy4 + 2;
fill(0, 0, 255);
ellipse(cx1, cy1, cradius1, cradius1);
ellipse(cx2, cy2, cradius2, cradius2);
ellipse(cx3, cy3, cradius3, cradius3);
ellipse(cx4, cy4, cradius4, cradius4);
ry1 = ry1 + 2;
ry2 = ry2 + 1;
ry3 = ry3 + 2;
ry4 = ry4 + 1;
ry1 = ry1 + 2;
if (ry1 > 500) {
ry1 = 0;
}
ry2 = moveY(ry2, 1);
ry3 = moveY(ry3, 2);
ry4 = moveY(ry4, 1);
if (rectRectIntersect(rx1, ry1, rx1 + rwidth1, ry1 + rwidth1, mouseX, mouseY, mouseX + imagewidth, mouseY + imageheight)) {
fill(random(255), random(255), random(255));
}
rect(rx1, ry1, rwidth1, rwidth1);
if (rectRectIntersect(rx2, ry2, rx2 + rwidth2, ry2 + rwidth2, mouseX, mouseY, mouseX + imagewidth, mouseY + imageheight)) {
fill(random(255), random(255), random(255));
}
rect(rx2, ry2, rwidth2, rwidth2);
if (rectRectIntersect(rx3, ry1, rx3 + rwidth1, ry1 + rwidth1, mouseX, mouseY, mouseX + imagewidth, mouseY + imageheight)) {
fill(random(255), random(255), random(255));
}
rect(rx3, ry1, rwidth1, rwidth1);
if (rectRectIntersect(rx1, ry1, rx1 + rwidth1, ry1 + rwidth1, mouseX, mouseY, mouseX + imagewidth, mouseY + imageheight)) {
fill(random(255), random(255), random(255));
}
rect(rx1, ry1, rwidth1, rwidth1);
image(img, mouseX, mouseY, imagewidth, imageheight);
}
int moveY(int y, int speed) {
y = y + speed;
if (y > 400) {
y = 0;
}
return y;
}
boolean rectRectIntersect(float left, float top, float right, float bottom,
float otherLeft, float otherTop, float otherRight, float otherBottom) {
return !(left > otherRight || right < otherLeft || top > otherBottom || bottom < otherTop);
}