class runningBox { int speed = 1; int startX = 0; int x = 0; int big = 5; int turn = 0; //0: T -> B; 1: R -> L; 2: B -> T; 3: L -> R int y = 0; boolean mousedriven; int ri = 160; int gi = 180; int bi = 220; int crichtung = -1; int number; int bigMIN, bigMAX, Height, Width, oldMouse; boolean matrix; void runningBox() { } void matrix() { matrix = !matrix; } int randomize(int IbigMIN, int IbigMAX, int Iturn, int Ispeed, int IHeight, int IWidth, boolean Imousedriven, boolean Imatrix) { if(Iturn < 0 || Iturn > 3) turn = int(random(0, 4)); else turn = Iturn; if(Ispeed < 0) speed = int(random(3, 12)); else speed = Ispeed; int maxiking; if(Imatrix) { number = int(random(2)); turn = 0; } if(turn == 0 || turn == 2) maxiking = IWidth; else maxiking = IHeight; if(turn == 2) y = height; else if(turn == 3) y = width; else y = 0; big = int(random(IbigMIN,IbigMAX)); if(!Imousedriven) { x = int(random(maxiking)); } else { if(turn == 0 || turn == 2) x = mouseX; else x = mouseY; } matrix = Imatrix; bigMIN = IbigMIN; bigMAX = IbigMAX; Height = IHeight; Width = IWidth; mousedriven = Imousedriven; return x + big; } void updatePosition() { if(!matrix) switch(turn) { case 0: y += speed + 16; if(y > height) { y=0; randomize(bigMIN, bigMAX, -1, -1, Height, Width, mousedriven,matrix); } break; case 1: y += speed + 16; if(y > width) { y=0; randomize(bigMIN, bigMAX, -1, -1, Height, Width,mousedriven,matrix); } break; case 2: y -= speed + 16; if(y < 0) { y=0; randomize(bigMIN, bigMAX, -1, -1, Height, Width,mousedriven,matrix); } break; case 3: y -= speed + 16; if(y < 0) { y = 0 + 16; randomize(bigMIN, bigMAX, -1, -1, Height, Width,mousedriven,matrix); } break; } else switch(turn) { case 0: y += speed; if(y > height) { y=0; randomize(bigMIN, bigMAX, -1, -1, Height, Width, mousedriven,matrix); } break; case 1: y += speed; if(y > width) { y=0; randomize(bigMIN, bigMAX, -1, -1, Height, Width,mousedriven,matrix); } break; case 2: y -= speed; if(y < 0) { y=0; randomize(bigMIN, bigMAX, -1, -1, Height, Width,mousedriven,matrix); } break; case 3: y -= speed; if(y < 0) { y = 0; randomize(bigMIN, bigMAX, -1, -1, Height, Width,mousedriven,matrix); } break; } } void makeIt() { //rectMode(CENTER); ri += crichtung; gi += crichtung; bi += crichtung; if(ri >= 255||ri<=100) crichtung *= -1; if(gi >= 255||gi<=100) crichtung *= -1; if(bi >= 255||bi<=100) crichtung *= -1; fill(color(ri,gi,bi)); if(!matrix) switch(turn) { case 0: case 2: rect(x,y,big,big); break; case 1: case 3: rect(y,x,big,big); break; } else switch(turn) { case 0: case 2: text(number,x,y); number = int(random(2)); break; case 1: case 3: text(number,y,x); number = int(random(2)); break; } } void mouse(boolean activate) { mousedriven = activate; } }