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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

with<br />

<strong>and</strong><br />

with<br />

void checkGroundCollision(Ground groundSegment, Orb orb, ➥<br />

Vect2D velocity, float damping) {<br />

void checkWallCollision() {<br />

void checkWallCollision(Orb orb, Vect2D velocity, float damping) {<br />

That’s really all you need to do (you can thank me later). The way I got this to work was by<br />

naming the parameters in the heads of the checkGroundCollision() <strong>and</strong><br />

checkWallCollision() functions the same names as the global variables declared in the<br />

main tab. Remember, local variables, which include parameters, take precedence over the<br />

same named global variables. Although this was an expedient solution, it can also lead to<br />

nasty, hard-to-track-down errors. I personally often use this approach, but it’s not for<br />

everybody, so enjoy <strong>and</strong> use it with caution.<br />

Figure 11-23. Asteroid Shower sketch<br />

There is one final thing I’d like to cover before retiring this chapter. However, before I do,<br />

I suggest playing with the Asteroid Shower sketch a bit first—doomsday scenario visualizations<br />

can be surprisingly cathartic.<br />

MOTION<br />

551<br />

11

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

Saved successfully!

Ooh no, something went wrong!