//how to add more small me to seek? // imagining large man is shadow can many men flock to it? // how to add personality // Seek_Arrive // Daniel Shiffman // Nature of Code, Spring 2009 // Two "boids" follow the mouse position // Implements Craig Reynold's autonomous steering behaviors // One boid "seeks" // One boid "arrives" // See: http://www.red3d.com/cwr/ float buildingWidth = 400; float buildingHeight = 250; float windowSize = 25; float gapSize = 15; float verticalGap = 10; Boid seeker; Boid arriver; void setup() { size(640,480); seeker = new Boid(new PVector(width/2+50,height/2),4.0,0.1,0,0); arriver = new Boid(new PVector(width/2-50,height/2),4.0,0.1,0,0); smooth(); } void draw() { background(255); stroke(255,0,0); int windowCount = 0; int x = 0; while(x < buildingWidth) { x += windowSize; if(x < buildingWidth) { windowCount++; } x += gapSize; } // count the number of windows vertically int rowCount = 0; int y = 0; while(y < buildingHeight) { y += windowSize; if(y < buildingHeight) { rowCount++; } y += verticalGap; } float xoffset = (windowCount*windowSize + (windowCount-5)*gapSize); float yoffset = (rowCount*windowSize + (rowCount)*verticalGap); float cy = yoffset - buildingHeight/2; for(int i = 0; i < rowCount; i++) { float cx = xoffset - buildingWidth/2; for(int j = 0; j < windowCount; j++) { rect(cx, cy, windowSize, windowSize); cx += windowSize + gapSize; } cy += windowSize + verticalGap; } //IS THERE A WAY TO MAKE THE BIG MAN INTO WHAT THE LITTLE MEN ARE ARRIVING AT? THEN HOW CAN THERE BE MORE LITTLE MEN //AND HOW CAN THE LITTLE MEN HAVE DIFFERENT SOMETHINGS? // Draw an ellipse at the mouse location int mx = mouseX; int my = mouseY; // fill(255); // stroke(255,0,0); // rect(mx,my,25,25); pushMatrix(); translate(mx, my); Man aMan = new Man(); stroke(0); aMan.render(); popMatrix(); // Call the appropriate steering behaviors for our agents seeker.seek(new PVector(mx,my)); seeker.run(); arriver.arrive(new PVector(mx,my)); arriver.run(); }