Spot [] spots = new Spot [columns];
Spot [] spots2 = new Spot [columns];
Spot [] spots3 = new Spot [columns];
//ββββββββββββSETUPββββββββββ-
void setup() {
size(505, 288);
images[0]= loadImage (βpic1.jpgβ);
images[1]= loadImage (βpic2.jpgβ);
images[2]= loadImage (βpic3.jpgβ);
images[3]= loadImage (βpic4.jpgβ);
images[4]= loadImage (βpic5.jpgβ);
images[5]= loadImage (βpic6.jpgβ);
images[6]= loadImage (βpic7.jpgβ);
images[7]= loadImage (βpic8.jpgβ);
images[8]= loadImage (βpic9.jpgβ);
images[9]= loadImage (βpic10.jpgβ);
images[10]= loadImage (βpic11.jpgβ);
images[11]= loadImage (βpic12.jpgβ);
images[12]= loadImage (βpic13.jpgβ);
images[13]= loadImage (βpic14.jpgβ);
images[14]= loadImage (βpic15.jpgβ);
images[15]= loadImage (βpic16.jpgβ);
images[16]= loadImage (βpic17.jpgβ);
images[17]= loadImage (βpic18.jpgβ);
images[18]= loadImage (βpic19.jpgβ);
images[19]= loadImage (βpic20.jpgβ);
images[20]= loadImage (βpic21.jpgβ);
for (int i = 0; i < pics.length; i++) {
//randomSeed();
pics [i] = new Picture (images[int(random(images.length/3))], i*width/pics.length, 0);
}
for (int i = 0; i < pics2.length; i++) {
pics2 [i] = new Picture (images[int(random(images.length/3, + (images.length/3*2 )))], i*width/pics.length, 100);
}
for (int i = 0; i < pics3.length; i++) {
pics3 [i] = new Picture (images[int(random(images.length/3*2, images.length))], i*width/pics.length, 200);
}
for(int j = 0; j <spots.length; j++){
spots[j] = new Spot(j*width/spots.length, 0);
}
for(int j = 0; j <spots2.length; j++){
spots2[j] = new Spot(j*width/spots.length, 100);
}
for(int j = 0; j <spots3.length; j++){
spots3[j] = new Spot(j*width/spots.length, 200);
}
}
//βββββββββββ-DRAWβββββββββββββ
void draw() {
background(255);
/* for(int j = 0; j<spots.length; j++){
spots[j].show();
}
for(int j = 0; j<spots2.length; j++){
spots2[j].show();
}
for(int j = 0; j<spots3.length; j++){
spots3[j].show();
}*/
for (int i = 0; i < pics.length; i++) {
pics[i].display();
pics[i].drag(mouseX, mouseY);
}
for (int i = 0; i < pics2.length; i++) {
pics2[i].display();
pics2[i].drag(mouseX, mouseY);
}
for (int i = 0; i < pics3.length; i++) {
pics3[i].display();
pics3[i].drag(mouseX, mouseY);
}
}
//βββββββββββMOUSE-PRESSEDβββββββββββββ-
void mousePressed() {
for (int i = 0; i < pics3.length; i++) {
pics3[i].clickedOn();
}
for (int i = 0; i < pics.length; i++) {
pics[i].clickedOn();
pics2[i].clickedOn();
}
}
//βββββββββββMOUSE-RELEASEDβββββββββββββ
void mouseReleased() {
for (int i = 0; i < pics3.length; i++) {
pics3[i].stopDragging();
}
for (int i = 0; i < pics.length; i++) {
pics[i].stopDragging();
pics2[i].stopDragging();
}
for (int i = 0; i < pics.length; i++) {
for (int j = 0; j < spots.length; j++) {
pics[i].check(spots3[j]);
pics2[i].check(spots2[j]);
pics2[i].check(spots[j]);
}
}
for (int i = 0; i < pics2.length; i++) {
for (int j = 0; j< spots2.length; j++) {
pics[i].check(spots[j]);
pics[i].check(spots2[j]);
pics2[i].check(spots3[j]);
}
}
for (int i = 0; i < pics3.length; i++) {
for (int j = 0; j x && mouseX y && mouseY < y + h) {
on =!on;
dragging = true;
}
}
void check(Spot s) {
if (dist(x,y, s.x, s.y) < 40) {
x = s.x;
y = s.y;
}
}
void stopDragging() {
dragging = false;
}
void drag(int mx, int my) {
if (dragging) {
x = mx + offsetX;
y = my + offsetY;
}
}
}
//ββββββββββββ-SPOT CLASSβββββββββββββ-
class Spot {
int x;
int y;
int w;
int h;
Spot(int tempX,int tempY) {
x = tempX;
y = tempY;
w = 100;
h = 100;
}
void show(){
fill(123);
rect(x, 0, width, height);
rect(x*100+0, 100, width, height);
rect(x, 200, width, height);
}
}