Monday 5 September 2011

Arrays and mousePressed

Experiments

In my final design I'd like to include multiple objects. Ben and Steven showed us the power of Arrays to not only create objects en masse, but apply properties to them all as well.  The trick is to use loops that address every instance (or locker) of the array and apply a value to them.

I created an example to show this at work that i'd like to implement it into my final design. It resembles those screensaver star-fields of old. If you hold the mouse button now mousePressed is activated creating a 'warp' effect

The difficult part was understanding how to individually animate each star. The method was to add a percentage of the distance between the stars and the centre of the screen to each star every time draw is run.

These projects really shows me how simple code can make something quite beautiful.

Star-field - Open Processing Link

No comments:

Post a Comment