rosejn/flocking — pull request #1 by ianbarber (2012-05-30 15:31:11+00:00)
Title: Add some mouse tracking. 

Adding in a couple of small features. Firstly, had to bump to clj 1.4.0 in order to get the mouse stuff working with this version of Quil. Then added a mouse update callback (:mouse-moved in the sketch) and included that in the update loop for the boids. The mouse position is stored in the canvas state as an atom, along with the boids.

The mouse pos is just subtracked from the current pos, and the whole direction is multiplied by the cohesion value so that the boids just drift that way. Note you have to click before the applet tracks the mouse.

I also reinstated the cohesion average, and added a bound function that just clips the speed to stop the boids getting ot of control. Haven't done the avoid function yet.