Processing: agents

In todays lecture we are learning about using agents.

float x, y;

float c;

^ declared variables
void setup(){
c = color(22,222,222);

^ assignment

void draw (){

x += random(-1, 1);
y += random(-1, 1);

^ update of variables
rect(x, y, 10, 10);

the updated variables can be put into their own voids:

void updateAgent(){

x += random(-1, 1);

y += random(-1, 1);

void drawAgent(){
rect(x, y, 10, 10);

Screen Shot 2014-10-31 at 15.40.27

The above classes code creates a small rectangle agent that floats and wiggles around the canvas. The below code creates wiggling agents at the point where the mouse is clicked. It also makes random coloured agents.

Screen Shot 2014-10-31 at 16.17.20 Screen Shot 2014-10-31 at 16.18.46

The workshop today fully explained everything from previous lectures and I feel that i understand processing a lot more. Although I’m still not comfortable with using the language to write by myself.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s