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 🙂

http://www.openprocessing.org/visuals/iframe.php?visualID=10494

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 @ processing.org
Have fun with the animation. Feel free to comment.

PS: If you want the code then go here.

Advertisements

1 Comment »

  1. Really cool stuff. Will try it sometime too. Thanks. 🙂

    Comment by Flavin — June 22, 2010 @ 3:15 am | Reply


RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: