//import processing.opengl.*; // BoomThread // stolen by: Chris Dillon (http://ubernub.com) // stolen from Ryan Alexander (http://onecm.com) BoomThread boom[] = new BoomThread[78]; int boomThreads; int activeBooms; PFont font; int now; int then; void setup() { size(900,400); frameRate(60); initThreads(); noStroke(); noSmooth(); font = loadFont("04b-08-8.vlw"); textFont(font); // note the starting time now = millis(); } void draw() { // note how much time has passed since our last loop then = now; float elapsed = 0; // wait for at least 1/100th of a second to pass while( elapsed < 1.0/100.0 ) { now = millis(); // compute elapsed time in seconds elapsed = (now - then) / 1000.0f; } background(0); for(int i=0; i 1) { // level-- plus a little extra for lost time between draws level = level - 1 - elapsed; try { // add random waiting to make each boom different Thread.sleep( (int)random(1, 10) ); } catch(InterruptedException e) { // do nothing, to the horror of good coding } } // while loop finished, level is 0 done = true; boomDestroyed(id); } public boolean isDone() { return done; } public void stop() { thread = null; } // this will magically be called by the parent once the user hits stop // this functionality hasn't been tested heavily so if it doesn't work, file a bug public void dispose() { stop(); } }