Arun Waves

June 19, 2010

Building a Boid system with Processing sketch

Filed under: Boid,code,Object Oriented Programming,Processing,sketch — Arun @ 5:38 pm

Recently I discovered a wonderful open source software, Processing, which is simple to use and great for visualization applications. My first Processing sketch 🙂

Click on the above link, it will open a browser (you would need Java in your machine). Once the app starts running, move your mouse pointer within the white square box and try to stay away from the red and the blue balls; for interesting response move your mouse pointer in circles of varying radii. I always wanted to say this……. “You take the blue pill, the story ends. You take the red pill, you stay in wonderland”.

This is my first step towards a Boid code. I wrote this code to learn PVector, vector manipulation and OOP (Class). This sketch creates a system with two elements (balls) that try to catch up to the mouse pointer. These elements bounce off the walls and have different accelerations. Red ball’s acceleration is twice that of the blue ball. To begin with the balls start at random locations and also have a maximum speed limitation.

Screen shot 1

Screen shot 2

Next step would be to make these elements interact with each other while chasing the target, which would make it a Boid code.

Took help from PVector and Objects tutorial @
Have fun with the animation. Feel free to comment.

PS: If you want the code then go here.


Blog at