04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

490<br />

speedX[i] = r<strong>and</strong>om(-5, 5);<br />

speedY[i] = r<strong>and</strong>om(-2, 2);<br />

}<br />

}<br />

void draw(){<br />

background(255);<br />

for (int i=0; i width-w[i]){<br />

x[i] = width-w[i];<br />

speedX[i]*=-1;<br />

}<br />

else if (x[i] < 0){<br />

x[i] = 0;<br />

speedX[i]*=-1;<br />

}<br />

else if (y[i] > height-h[i]){<br />

y[i] = height-h[i];<br />

speedY[i]*=-1;<br />

}<br />

else if (y[i] < 0){<br />

y[i] = 0;<br />

speedY[i]*=-1;<br />

}<br />

}<br />

// stop draw when timelimit reached<br />

if (millis() >= timeLimit*1000){<br />

noLoop();<br />

}<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!