[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Using Numeric & Surfarray with alpha values



Mike Rotondo wrote:

We are writing a 2D particle engine and we would like to render each particle with gradually decreasing alpha values. However, our original image for the particles has per-pixel alpha, so we can't use set-alpha. So, we are going to have to modify each pixel's alpha value ith Numeric, it seems.


IMHO you are approaching this problem from the wrong angle. Instead either render the particles as an animation w/ decreasing alpha values (# frames = fade-time/frames-per-second), or better yet render with OpenGL.

If you render with openGL, alpha fade is easily done by sticking the particle image into a Texture, pasting that on a Quad, and varrying the alpha part of the quad's color with glColor4ub(255,255,255,desiredAlpha). Decreasing "desiredAlpha" will fade a particle -- even if you're using per pixel alpha for the texture.

At least, this is what works for me.
-Jasper