void setup(){ size(700,500, OPENGL); background(0); smooth(); stopper = true; OCR = loadFont("OCR.vlw"); Minim.start(this); guitar1 = Minim.loadSample("Guitar1.WAV"); //loads the sound samples into memory for quick playback guitar2 = Minim.loadSample("Guitar2.WAV"); guitar3 = Minim.loadSample("Guitar3.WAV"); guitar4 = Minim.loadSample("Guitar4.WAV"); guitar5 = Minim.loadSample("Guitar5.WAV"); organ1 = Minim.loadSample("FHP_CARA_RHODES_C2.WAV"); organ2 = Minim.loadSample("RHODES_G2.WAV"); organ3 = Minim.loadSample("RHODES_C3.WAV"); organ4 = Minim.loadSample("RHODES_G3.WAV"); organ5 = Minim.loadSample("RHODES_C4.WAV"); drum1 = Minim.loadSample("Snare009.wav"); drum2 = Minim.loadSample("Kick023.wav"); drum3 = Minim.loadSample("Junk21.wav"); drum4 = Minim.loadSample("Hat037.wav"); drum5 = Minim.loadSample("Shaker08.wav"); sax1 = Minim.loadSample("Sax1.wav"); sax2 = Minim.loadSample("Sax2.wav"); sax3 = Minim.loadSample("Sax3.wav"); sax4 = Minim.loadSample("Sax4.wav"); sax5 = Minim.loadSample("Sax5.wav"); bass1 = Minim.loadSample("Bass1.wav"); bass2 = Minim.loadSample("Bass2.wav"); bass3 = Minim.loadSample("Bass3.wav"); bass4 = Minim.loadSample("Bass4.wav"); bass5 = Minim.loadSample("Bass5.wav"); elektro1 = Minim.loadSample("Elektro1.wav"); elektro2 = Minim.loadSample("Elektro2.wav"); elektro3 = Minim.loadSample("Elektro3.wav"); elektro4 = Minim.loadSample("Elektro4.wav"); elektro5 = Minim.loadSample("Elektro5.wav"); bg = new Background(35, GRID_SPACE); restartBtn = new RestartButton((width - (GRID_SPACE * 3)),(height - (GRID_SPACE * 2))); leadBtns = new LeadButtons(); keysBtns = new KeysButtons(); drumsBtns = new DrumsButtons(); speedBtns = new SpeedButtons(); for (int i=0; i= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } for(int i=0; i TTimer)){ if((bl[i].direction == R) && ((millis() - tee1[w].dirTimer) > TTimer)){ float x = tee1[w].x; float y = tee1[w].y; bl[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, U, RED_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } if((bl[i].direction == R) && ((millis() - tee1[w].dirTimer) < TTimer)){ float x = tee1[w].x; float y = tee1[w].y; bl[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, L, RED_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } else if(bl[i].direction == L){ float x = tee1[w].x; float y = tee1[w].y; bl[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, U, RED_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } } if((tee2[w].makeNewBall == true) && (tee2[w].newBallTimer > TTimer)){ if((bl[i].direction == R) && ((millis() - tee2[w].dirTimer) > TTimer)){ float x = tee2[w].x; float y = tee2[w].y; bl[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, D, RED_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } if((bl[i].direction == R) && ((millis() - tee2[w].dirTimer) < TTimer)){ float x = tee2[w].x; float y = tee2[w].y; bl[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, L, RED_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } else if(bl[i].direction == L){ float x = tee2[w].x; float y = tee2[w].y; bl[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, D, RED_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } } } } // close ball visibility test if(bl2[i].ballOnScreen()){//if the ball is on the screen bl2[i].display();//draw the ball bl2[i].move();//make the ball move for(int w =0; w TTimer)){ if((bl2[i].direction == R) && ((millis() - tee1[w].dirTimer) > TTimer)){ float x = tee1[w].x; float y = tee1[w].y; bl2[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, U, GREEN_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } if((bl2[i].direction == R) && ((millis() - tee1[w].dirTimer) < TTimer)){ float x = tee1[w].x; float y = tee1[w].y; bl2[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, L, GREEN_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } else if(bl2[i].direction == L){ float x = tee1[w].x; float y = tee1[w].y; bl2[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, U, GREEN_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } } if((tee2[w].makeNewBall == true) && (tee2[w].newBallTimer > TTimer)){ if((bl2[i].direction == R) && ((millis() - tee2[w].dirTimer) > TTimer)){ float x = tee2[w].x; float y = tee2[w].y; bl2[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, D, GREEN_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } if((bl2[i].direction == R) && ((millis() - tee2[w].dirTimer) < TTimer)){ float x = tee2[w].x; float y = tee2[w].y; bl2[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, L, GREEN_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } else if(bl2[i].direction == L){ float x = tee2[w].x; float y = tee2[w].y; bl2[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, D, GREEN_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } } } }//close visibility test if(bl3[i].ballOnScreen()){//if the ball is on the screen bl3[i].display();//draw the ball bl3[i].move();//make the ball move for(int w =0; w TTimer)){ if((bl3[i].direction == R) && ((millis() - tee1[w].dirTimer) > TTimer)){ float x = tee1[w].x; float y = tee1[w].y; bl3[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, U, PURP_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } if((bl3[i].direction == R) && ((millis() - tee1[w].dirTimer) < TTimer)){ float x = tee1[w].x; float y = tee1[w].y; bl3[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, L, PURP_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } else if(bl3[i].direction == L){ float x = tee1[w].x; float y = tee1[w].y; bl3[ballIndex].reset ((x + (GRID_SPACE/2)), (y + (GRID_SPACE/2)), GRID_SPACE, 4.0, U, PURP_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } } if((tee2[w].makeNewBall == true) && (tee2[w].newBallTimer > TTimer)){ if((bl3[i].direction == R) && ((millis() - tee2[w].dirTimer) > TTimer)){ float x = tee2[w].x; float y = tee2[w].y; bl3[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, D, PURP_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } if((bl3[i].direction == R) && ((millis() - tee2[w].dirTimer) < TTimer)){ float x = tee2[w].x; float y = tee2[w].y; bl3[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, L, PURP_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } else if(bl3[i].direction == L){ float x = tee2[w].x; float y = tee2[w].y; bl3[ballIndex].reset ((x + (GRID_SPACE/2)), (y - (GRID_SPACE/2)), GRID_SPACE, 4.0, D, PURP_BALL); ballIndex++; ballTotal++; if (ballIndex >= (num)) {//resets the ball index variable, so you can't get an index out of bounds error ballIndex = 0; } } } } } if(leadBtns.playGuitar == false){ sax = true; } else { sax = false; } if(keysBtns.playKeys == false){ bass = true; } else { bass = false; } if(drumsBtns.playDrums == false){ elektro = true; } else { elektro = false; } bl[i].speed = speedBtns.speed; bl2[i].speed = speedBtns.speed; bl3[i].speed = speedBtns.speed; }//close the ball array for loop bg.display(); restartBtn.display(); leadBtns.display(); keysBtns.display(); drumsBtns.display(); speedBtns.display(); drawPipes(); // draw the pipes //================================================= for(int w =0; w= (GRID_SPACE/2)){ el[w].x = el[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ el[w].x = el[w].x - (j); } if(n >= (GRID_SPACE/2)){ el[w].y = el[w].y + (GRID_SPACE-n); } else if (n < (GRID_SPACE/2)){ el[w].y = el[w].y - (n); } } if (el_2[w].pipeDrag == true){//if you are dragging on an el1 pipe el_2[w].x = mouseX;//make the pipe follow the mouse el_2[w].y = mouseY; el_2[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = el_2[w].x % GRID_SPACE; float n = el_2[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ el_2[w].x = el_2[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ el_2[w].x = el_2[w].x - (j); } if(n >= (GRID_SPACE/2)){ el_2[w].y = el_2[w].y + (GRID_SPACE-n); } else if (n < (GRID_SPACE/2)){ el_2[w].y = el_2[w].y - (n); } } if (el_3[w].pipeDrag == true){//if you are dragging on an el3 pipe el_3[w].x = mouseX;//make the pipe follow the mouse el_3[w].y = mouseY; el_3[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = el_3[w].x % GRID_SPACE; float n = el_3[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ el_3[w].x = el_3[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ el_3[w].x = el_3[w].x - j; } if(n >= (GRID_SPACE/2)){ el_3[w].y = el_3[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ el_3[w].y = el_3[w].y - n; } } if (el_4[w].pipeDrag == true){//if you are dragging on an el3 pipe el_4[w].x = mouseX;//make the pipe follow the mouse el_4[w].y = mouseY; el_4[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = el_4[w].x % GRID_SPACE; float n = el_4[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ el_4[w].x = el_4[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ el_4[w].x = el_4[w].x - j; } if(n >= (GRID_SPACE/2)){ el_4[w].y = el_4[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ el_4[w].y = el_4[w].y - n; } } if (vert[w].pipeDrag == true){//if you are dragging on an el3 pipe vert[w].x = mouseX;//make the pipe follow the mouse vert[w].y = mouseY; vert[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = vert[w].x % GRID_SPACE; float n = vert[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ vert[w].x = vert[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ vert[w].x = vert[w].x - j; } if(n >= (GRID_SPACE/2)){ vert[w].y = vert[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ vert[w].y = vert[w].y - n; } } if (horz[w].pipeDrag == true){//if you are dragging on an el3 pipe horz[w].x = mouseX;//make the pipe follow the mouse horz[w].y = mouseY; horz[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = horz[w].x % GRID_SPACE; float n = horz[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ horz[w].x = horz[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ horz[w].x = horz[w].x - j; } if(n >= (GRID_SPACE/2)){ horz[w].y = horz[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ horz[w].y = horz[w].y - n; } } if (tee1[w].pipeDrag == true){//if you are dragging on an el3 pipe tee1[w].x = mouseX;//make the pipe follow the mouse tee1[w].y = mouseY; tee1[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = tee1[w].x % GRID_SPACE; float n = tee1[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ tee1[w].x = tee1[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ tee1[w].x = tee1[w].x - j; } if(n >= (GRID_SPACE/2)){ tee1[w].y = tee1[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ tee1[w].y = tee1[w].y - n; } } if (tee2[w].pipeDrag == true){//if you are dragging on an el3 pipe tee2[w].x = mouseX;//make the pipe follow the mouse tee2[w].y = mouseY; tee2[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = tee2[w].x % GRID_SPACE; float n = tee2[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ tee2[w].x = tee2[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ tee2[w].x = tee2[w].x - j; } if(n >= (GRID_SPACE/2)){ tee2[w].y = tee2[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ tee2[w].y = tee2[w].y - n; } } if (diag1[w].pipeDrag == true){//if you are dragging on an el3 pipe diag1[w].x = mouseX;//make the pipe follow the mouse diag1[w].y = mouseY; diag1[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = diag1[w].x % GRID_SPACE; float n = diag1[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ diag1[w].x = diag1[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ diag1[w].x = diag1[w].x - j; } if(n >= (GRID_SPACE/2)){ diag1[w].y = diag1[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ diag1[w].y = diag1[w].y - n; } } if (diag2[w].pipeDrag == true){//if you are dragging on an el3 pipe diag2[w].x = mouseX;//make the pipe follow the mouse diag2[w].y = mouseY; diag2[w].lightUpDrag(); //this code snaps the pipe piece to a grid float j = diag2[w].x % GRID_SPACE; float n = diag2[w].y % GRID_SPACE; if(j >= (GRID_SPACE/2)){ diag2[w].x = diag2[w].x + (GRID_SPACE-j); } else if (j < (GRID_SPACE/2)){ diag2[w].x = diag2[w].x - j; } if(n >= (GRID_SPACE/2)){ diag2[w].y = diag2[w].y + (GRID_SPACE - n); } else if (n < (GRID_SPACE/2)){ diag2[w].y = diag2[w].y - n; } } } } //===================================== void drawPipes(){ for(int w=0; w (width - (GRID_SPACE * 3))) && (mouseY > height - (GRID_SPACE * 3))){ restart(); } for(int i=0; i(height - (GRID_SPACE*3))){ el[i].x = (GRID_SPACE*2); el[i].y = (height - GRID_SPACE); } if(el_2[i].y >(height - (GRID_SPACE*3))){ el_2[i].x = (GRID_SPACE*5); el_2[i].y = (height - GRID_SPACE); } if(el_3[i].y >(height - (GRID_SPACE*3))){ el_3[i].x = (GRID_SPACE*8); el_3[i].y = (height - GRID_SPACE); } if(el_4[i].y >(height - (GRID_SPACE*3))){ el_4[i].x = (GRID_SPACE*11); el_4[i].y = (height - GRID_SPACE); } if(vert[i].y >(height - (GRID_SPACE*3))){ vert[i].x = (GRID_SPACE*13); vert[i].y = (height - GRID_SPACE); } if(horz[i].y >(height - (GRID_SPACE*3))){ horz[i].x = (GRID_SPACE*16); horz[i].y = (height - (GRID_SPACE * 1.5)); } if(tee1[i].y >(height - (GRID_SPACE*3))){ tee1[i].x = (GRID_SPACE*19); tee1[i].y = (height - GRID_SPACE); } if(tee2[i].y >(height - (GRID_SPACE*3))){ tee2[i].x = (GRID_SPACE*23); tee2[i].y = (height - GRID_SPACE); } if(diag1[i].y >(height - (GRID_SPACE*3))){ diag1[i].x = (GRID_SPACE*27); diag1[i].y = (height - GRID_SPACE); } if(diag2[i].y >(height - (GRID_SPACE*3))){ diag2[i].x = (GRID_SPACE*29); diag2[i].y = (height - GRID_SPACE); } el[i].pipeDrag = false; el_2[i].pipeDrag = false; el_3[i].pipeDrag = false; el_4[i].pipeDrag = false; vert[i].pipeDrag = false; horz[i].pipeDrag = false; tee1[i].pipeDrag = false; tee2[i].pipeDrag = false; diag1[i].pipeDrag = false; diag2[i].pipeDrag = false; stopper = true; } } void restart(){ mp = false; //mp stands for mouse pressed, this turns true on mouse down drag = false; //variable that turns true when a mouse drag is begun dragging = false; stopper = true; num = 100; //number of balls to allocate memory for ballIndex = 0; ballTotal = 0; //variables used for creating balls and cycling through array if more than 1000 are created lastSec = -1; //variable used in timer function sax = false; leadBtns.playGuitar = true; keysBtns.playKeys = true; drumsBtns.playDrums = true; bass = false; elektro = false; speed = 5; speedBtns.speed = 5; for(int w =0; w