dancer a; dancer b; dancer d; dancer e; dancer f; dancer g; dancer u; dancer v; formation A; formation B; formation C; formation D; formation E; int speed = 4; int s = 10; // size of dancers int m = 40; // no. of panels boolean nextAction = false; int start; int action = 0; import ddf.minim.*; AudioPlayer player; Minim minim; void setup() { size(screen.width,screen.height); background(#a0a0a0); a = new dancer(color(50,50,50)); b = new dancer(color(50,50,50)); f = new dancer(color(200,0,150)); g = new dancer(color(100,0,250)); e = new dancer(color(200,150,0)); d = new dancer(color(0,250,150)); u = new dancer(color(200,0,150)); v = new dancer(color(100,0,250)); A = new formation(); B = new formation(); C = new formation(); D = new formation(); E = new formation(); C.setLeaderFormation(A); C.setFollowerFormation(B); A.setLeaderDancer(d); A.setFollowerDancer(e); B.setLeaderDancer(f); B.setFollowerDancer(g); A.setDir(1); B.setDir(1); C.setDir(-1); minim = new Minim(this); player = minim.loadFile("nutcracker.mp3"); player.play(); player.loop(1); } void stop() { player.close(); minim.stop(); super.stop(); } void draw() { background(#a0a0a0); D.draw(width/3,height/2,0); C.draw(2*width/3,height/2,0); E.draw(width/2,-height,0); if (frameCount % 107 == 0 && nextAction) { nextAction = false; action++; switch(action) { case 1: C.EckmannHilton(); break; case 2: C.EckmannHilton(); break; case 3: C.reset(0); C.setLeaderDancer(f); C.setFollowerDancer(g); C.setDir(1); D.reset(0); D.setLeaderDancer(u); D.setFollowerDancer(v); D.setDir(1); E.setLeaderDancer(e); E.setFollowerDancer(d); break; case 4: C.setLeaderFormation(A); C.setFollowerFormation(B); A.setLeaderDancer(a); A.setFollowerDancer(f); B.setLeaderDancer(g); B.setFollowerDancer(b); C.lineUpChildren(); A.setDir(-1); B.setDir(-1); break; case 5: C.EckmannHilton(); break; case 6: C.setLeaderDancer(g); C.setFollowerDancer(f); E.setLeaderDancer(a); E.setFollowerDancer(b); break; case 7: action = 2; break; } } } void keyPressed() { switch (key) { case 'a': speed = speed/2; break; case 'z': speed = speed*2; break; default: nextAction = true; } } void mousePressed() { nextAction = true; } class dancer { float mx; // current coordinate float my; float mt; float d; // direction float t; // angle float tp; // parent angle color c; // colour dancer(color ic) { mx = width/2; my = 0; d = 0; t = 0; c = ic; } void reset () { d = 0; t = 0; } void draw(float cx, float cy, float pt) { float dx = cx - mx; float dy = cy - my; float dl = sqrt(sq(dx) + sq(dy)); if (dl > 10) { cx = mx + 10*dx/dl; cy = my + 10*dy/dl; } mx = cx; my = cy; t = t+d/speed; noStroke(); for (int i=0;i