float decB = 0.7; // decrementing bounce class bObject // breakableObject { float x, y; float vx, vy; float s; public boolean hotFlag; public boolean pulseFlag; public boolean voltageFlag; public boolean coldFlag; public float shrink; public boolean alive; public boolean toKill; public float maxHeatSize; float bRed, bGreen, bBlue; int whichType; //KEEP WHICH TYPE FOR THE COLOR CYCLES bObject(float X, float Y, float S, int which, float r, float g, float b) { whichType = which; bRed = r; bGreen = g; bBlue = b; while(vx == 0) vx = random(-5,5); while(vy == 0) vy = random(-7,7); x = X+vx; y = Y+vy; s = S; hotFlag = false; pulseFlag = false; voltageFlag = false; alive = true; shrink = sc; toKill=false; maxHeatSize = (float)((Math.random()*60)+110); } //here is where the two circles are created! float a = 0.0; float g = 0.0; float sc = 45.0f; float maxSC = random(30,90); float coldmax = random(30,90); float smallcircle=random(5.0,20.0); float dir = 1.0f; float colddir = 1.0f; void bdraw() { //this flag checks to see if the hot sensor was triggered update(); //this flag checks to see if the voltage sensor was triggered. If true it makes the blobs start to shiver. if(voltageFlag){ hotmove(); } if(coldFlag){ coldsize(); } if(this.toKill && this.alive){ this.deleteMe(); } //value for pulsation scaling //if the hot sensor is triggered the if(!pulseFlag){ setSize(); } /////////////////////////////////////////////////////////////////////////////////////////////////////// //here is where the ellipses are created pushMatrix(); //first group translate(x, y); color c1 = color(bRed,bGreen,bBlue,170); fill(c1); noStroke(); ellipse(0,0,sc,sc); fill(bRed,bGreen,bBlue); noStroke(); ellipse(0,0,(sc-20),(sc-20)); // scale(g); fill(0,0,0); ellipse(0, 0, (smallcircle), (smallcircle)); popMatrix(); //} /////////////////////////// } //this makes the blobs pulsate void setSize(){ if(sc < maxSC && sc > 20){ sc += dir; } if(sc >= maxSC) { dir = (-1.0); sc += dir; } if(sc <= 20){ dir = 1.0f; sc+= dir; } } //this makes the blobs shrink in size when triggered by the cold sensor void coldsize(){ pulseFlag = false; sc = (shrink); println(shrink); if (sc < smallcircle){ sc=(smallcircle + random(7,37)); } if (sc > smallcircle){ dir = (-1.0); shrink += dir; sc = shrink; } } //this gets the blobs to move around on the screen void update() { if(x+vx>((width)) || x+vx<0) { if(x+vx>(width)) x = (width); if(x+vx<0) x = 0; vx *= (-1)*decB; vy *= decB; } if(y+vy>(height) || y+vy<0) { if(y+vy>(height)) y = (height); if(y+vy<0) y = 0; vx *= decB; vy *= 0-decB; } x += vx; y += vy; } //This is for when the blobs collide void collide(bObject bo) { float X = bo.x; float Y = bo.y; float R = bo.s/2; float M = bo.s/2; float deltax = X-x; float deltay = Y-y; float d = sqrt(pow(deltax,2)+pow(deltay,2)); if ( d < s + R && d > 0 ) { float dD = s + R - d; float theta = atan2(deltay,deltax); vx = -dD*cos(theta)*M/(s+M); vy = -dD*sin(theta)*M/(s+M); } } //This makes the blobs move when voltage is triggered void hotmove() { float direction; float speed; float dev; float ballsize; ballsize = s; direction = (TWO_PI/100.0) * random(0, 100); speed = -.1; dev = (TWO_PI/100.0) * random(2, 10); for(int i = 0; i < sys.numO; i++){ direction += (0.5*dev) - ((dev/20) * random(0, 20)); x += speed * cos(direction); y += speed * sin(direction); } } public void deleteMe(){ this.vx = 0; this.vy = 0; this.sc--; this.pulseFlag = true; this.voltageFlag = false; if(this.sc <= 0){ this.alive = false; blobsAlive--; this.toKill = false; } } public void heatColor(){ if(whichType == 1){ //GRAY if(bRed > 255) bRed -=2; if(bRed < 255) bRed+=2; if(bGreen > 156) bGreen-=2; if(bGreen < 156) bGreen+=2; if(bBlue < 56) bBlue+=2; if(bBlue > 56) bBlue-=2; } else { //ORANGE if(bRed > 255) bRed --; if(bRed < 255) bRed++; if(bGreen > 255) bGreen--; if(bGreen < 255) bGreen++; if(bBlue < 122) bBlue++; if(bBlue > 122) bBlue--; } } public void coolColor(){ if(whichType == 1){ //GRAY if(bRed > 0) bRed --; if(bRed < 0) bRed++; if(bGreen > 0) bGreen--; if(bGreen < 0) bGreen++; if(bBlue < 0) bBlue++; if(bBlue > 0) bBlue--; } else { //ORANGE if(bRed > 0) bRed -=8; if(bRed < 0) bRed++; if(bGreen > 56) bGreen-=5; if(bGreen < 56) bGreen++; if(bBlue < 112) bBlue++; if(bBlue > 112) bBlue--; } } public void normalizeColor(){ if(whichType == 1){ //GRAY if(bRed > 200) bRed --; if(bRed < 200) bRed++; if(bGreen > 200) bGreen--; if(bGreen < 200) bGreen++; if(bBlue < 200) bBlue++; if(bBlue > 200) bBlue--; } else { //ORANGE if(bRed > 255) bRed --; if(bRed < 255) bRed++; if(bGreen > 255) bGreen--; if(bGreen < 255) bGreen++; if(bBlue < 122) bBlue++; if(bBlue > 122) bBlue--; } } public void voltColor(){ if(whichType == 1){ //GRAY if(bRed > 255) bRed --; if(bRed < 255) bRed++; if(bGreen > 255) bGreen--; if(bGreen < 255) bGreen++; if(bBlue < 122) bBlue++; if(bBlue > 122) bBlue--; } else { //ORANGE if(bRed > 255) bRed --; if(bRed < 255) bRed++; if(bGreen > 255) bGreen--; if(bGreen < 255) bGreen++; if(bBlue < 122) bBlue++; if(bBlue > 122) bBlue--; } } }