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 />

542<br />

/*******************************************<br />

* Non-orthogonal Collision with<br />

* Multiple Ground Segments<br />

*******************************************<br />

* Based on Keith Peters's Solution in<br />

* Foundation ActionScript Animation:<br />

* Making Things Move!<br />

* http://www.friendsofed.com/book.html? ➥<br />

* isbn=1590597915<br />

*******************************************/<br />

Orb orb;<br />

Vect2D velocity;<br />

float gravity = .05, damping = 0.8;<br />

int segments = 40;<br />

Ground[] ground = new Ground[segments];<br />

float[] peakHeights = new float[segments+1];<br />

void setup(){<br />

size(400, 400);<br />

smooth();<br />

orb = new Orb(50, 50, 3);<br />

velocity = new Vect2D(.5, 0);<br />

// calculate ground peak heights<br />

for (int i=0; i

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

Saved successfully!

Ooh no, something went wrong!