/* tmnt_arrays.pde Edited by Justin Hsia, Sam Wolfson (orig. Larry Synder) Draws four abstracted Teenage Mutant Ninja Turtles. We started with old generalized TMNT code (tmnt.pde), then: 1) created arrays for x position and mask colors of all 4 TMNTs 2) arbitrarily assigned indices for each turtle 3) used the arrays in a for-loop to draw the characters */ // var: tmnt_x[0], tmnt_x[1], tmnt_x[2], tmnt_x[3] // donatello, raphael, leonardo, michaelangelo int[] tmntX = new int[4]; int[] tmntC = new color[4]; void setup() { size(500, 500); noStroke(); tmntX[0] = 0; // Donatello starts at left edge of canvas tmntC[0] = color(88, 44, 141); // purple tmntX[1] = 460; // Raphael starts at right edge of canvas tmntC[1] = color(255, 0, 0); // red tmntX[2] = 100; // Leonardo stays at 100 tmntC[2] = color(0, 0, 255); // blue tmntX[3] = 300; // Michaelangelo stays at 300 tmntC[3] = color(245, 168, 12); // orange } // draw Donatello and Raphael moving, others stay put void draw() { background(255, 245, 220); // paint over drawing canvas int i = 0; while (i < 4) { tmnt(tmntX[i], tmntC[i]); i = i + 1; } /* the following statements were replaced with the loop above */ //tmnt(tmntX[0],color(88,44,141)); // draw donatello with purple mask //tmnt(tmntX[1],color(255,0,0)); // draw raphael with red mask //tmnt(tmntX[2],color(0,0,255)); // draw leonardo with blue mask //tmnt(tmntX[3],color(245,168,12));// draw michaelangelo with orange mask //<>// tmntX[0] = min(tmntX[0] + 1, 460); // donatello moves to the right slowly //<>// tmntX[1] = max(tmntX[1] - 2, 0); // raphael moves to the left a bit faster } // parameterized function to draw any of the TMNT void tmnt(int xPos, color mask) { fill(0, 100, 0); // dark green rect(xPos, 182, 40, 15); // top of head fill(mask); // specified mask color rect(xPos, 197, 40, 6); // bandana mask fill(0, 100, 0); // dark green rect(xPos, 203, 40, 20); // bottom of head fill(219, 136, 0); // dark yellow rect(xPos, 223, 40, 50); // shell fill(0, 100, 0); // dark green rect(xPos, 273, 40, 45); // lower body }