LED光立方制作全过程(三十六)
0赞
发表于 5/13/2011 6:37:23 PM
阅读(2029)
Step 57Software: Effect 1, rain

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!


