class Balloon { int xpos; int ypos; float h; float BalloonValue; float maxValue = 34.0; float minValue = 5.0; float concentric; // for balloon 3D effect float offset; int colorValue; // which color is it int Alpha; int popValue; // is it popped int rowNum; boolean touching; // is it being touched with mouse? Balloon (int _xpos, int _ypos, int _rowNum) { xpos = _xpos + 22; ypos = _ypos + 20; rowNum = _rowNum; h = random(2*PI); // bob starts at random point in cycle BalloonValue = minValue; colorValue = 0; // start teal Alpha = 160; popValue = 0; // not popped boolean touching = false; } void drawBalloon() { h += 0.2; // speed of the bob concentric = 1.0; // affects concentric ellipse to create fake 3D effect switch(popValue) { case 0: // if unpopped, draw balloon for (int i = 0; i < 10; i++ ) { // Balloon Tint switch(colorValue) { case 0: fill(35+(i*22),155+(i*10),135+(i*12),Alpha); break; case 1: fill(255, 75+(i*18),175+(i*8),Alpha); break; case 2: fill(255,155+(i*10),75+(i*18),Alpha); break; } offset = BalloonValue/(20*concentric); ellipse(xpos-offset, (ypos+(2*sin(h)))-offset, BalloonValue*concentric, (BalloonValue*1.2)*concentric); concentric = (concentric*0.85)+0.01; } break; case 1: // if it's popped, image (pop,xpos-10,ypos-10,20,20); // draw the explosion image popValue = 0; // and unpop break; } } void touch() { if (mouseX >= xpos - (17) && mouseX <= xpos+(17) && mouseY >= ypos-(17) && mouseY <= ypos+(17)) { touching=true; } else { touching=false; } } void checkBalloon() { if (touching == true) { BalloonValue += 2.0; } if (BalloonValue > maxValue) { // if it's too big, pop pop(); } } void pop() { BalloonValue = minValue; // reset to starting size colorValue++; // go to next color colorValue = colorValue % 3; // hit end go back. mod to restart color cycle. popValue = 1; // says "it's popped" PopChannel[rowNum].play(1); //println(rowNum+" popped"); } }