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.

Figure 11-22. Non-orthogonal Collision with Multiple Ground Segments<br />

sketch<br />

Stage 3: Asteroid shower<br />

In the final stage of the sketch, shown in Figure 11-23, I’ll add multiple orbs to the segmented<br />

ground plane. In addition, in the hope of creating something a little more visually<br />

interesting, I’ll convert the flat, undulating ground plane to a curved, undulating planet,<br />

<strong>and</strong> I’ll attach an image map to the geometry. I’ll also add inspirational twinkling stars <strong>and</strong><br />

some fiery colors to the asteroid shower.<br />

As with stage 2, the Ground, Orb, <strong>and</strong> Vect2D classes remain unchanged. You just need to<br />

edit the code in the main tab <strong>and</strong> add some parameters to the checkGroundCollision()<br />

<strong>and</strong> checkWallCollision() functions. Following is the main tab code (note that, since the<br />

majority of the following code is different from the last sketch, I didn’t put the changes in<br />

bold):<br />

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

* Asteroid Shower<br />

* Non-orthogonal Collision with<br />

* Multiple Ground Segments <strong>and</strong><br />

* Multiple Orbs<br />

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

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

* Foundation ActionScript Animation:<br />

MOTION<br />

545<br />

11

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

Saved successfully!

Ooh no, something went wrong!