Step 57: Software: Effect 1, rain

IMG_6150.JPG
IMG_6148.JPG
effect_rain_2.png
Lets start with one of the simplest effects.

In effect.c you will find the function effect_rain(int iterations).

This effect adds raindrops to the top layer of the cube, then lets them fall down to the bottom layer.

Most of the effects have a main for() loop that loops from i=0 to i < iterations.
effect_rain(int iterations) only takes one argument, which is the number of iterations.

Inside the iteration loop, the function does the following:

1) Create a random number between 0 and 3, lets call it n here.

2) Loop a for() loop n number of times.

3) For each iteration of this loop, place a pixel on layer 7 (z=7) at random x and y coordinates.

4) Delay for a while

5) Shift the contents of the entire cube along the Z axis by -1 positions. This shifts everything down one level.

This is a pretty simple effect, but it works!



 
Remove these adsRemove these ads by Signing Up
ung says: Mar 25, 2011. 7:11 AM
very cool !
ancienthart says: Jan 3, 2011. 5:49 PM
This could be altered to make a "matrix" effect. :)
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!