#165551 - chatterbug89 - Sat Dec 27, 2008 8:34 am
well, it's 1:30AM and I've never tried any sort of snowfall type thing, but posibly one way you could do it is like this (I'm not sure if it would be too slow or not though):
1. randomly draw dots on a line at the very top of the screen.
2. move every line down one pixel individually by copying to another tempory buffer.
3. Before any pixel is moved down, check to see if the pixel below it is white. If it is, do not move that particlar pixel down.
4. Draw your new random dots on the top line.
5. copy the buffer to your framebuffer.
6. repeat, so on and so on.
So basicly, you draw a line and move each pixel down checking to see if there is any "snow" underneth it before moving it down.
I think that shouldn't be too hard to do :) I kind of feel like doing it for fun now lol. Also, you should be able to build off of the idea above to do something with the multi-colored snow affect type thing in that demo if you wish.
#165558 - silent_code - Sat Dec 27, 2008 5:41 pm
You could (it depends on the implementation and needs) replace the pixel lookup with an array of column heights for each vertical line. Basically, you would index with the snow particle's x coordinate into the array and compare it's y coordinate to the stored height value (how many snow particlas are stacked at that vertical line / x coordinate).
That could speed up the thing a little, I guess. :^)
@ everybody: I hope you had some nice and relaxing holidays! :^D
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.