Game Programming Effects

This is a discussion on Game Programming Effects within the Game Programming forums, part of the General Programming Boards category; Hi,
I was wondering..is there a way to create cool "pulse" effects without shaders? Allegro doesn't seem to support and ...

Game Programming Effects

Hi,
I was wondering..is there a way to create cool "pulse" effects without shaders? Allegro doesn't seem to support and OpenGl is too advanced for me, looks very hard to understand.

I have made a 2d game that looks absolutely boring and I would like to add some effects to it.
I tried the neon pharmacy effect thingy as a start, you know from green to red using line draws, but it doesn't work at all. The color remains the same, and the delay loop I used to control change doesn't make a difference...

so any way I can add some effects, beginner effects and start from there? Thanks

I think Sipher has the right idea, but if you don't want to use images maybe you should look at a really simple particle engine or just particle effects. You could probably find a simple one somewhere or even write your own. I've never written a particle engine, but I bet it'd be fun.

Hey, thanks for replying.
@JohnL
The thing is I don't think allegro supports alpha blending or concepts like that. Even if it does, I wouldn;t know what to do.

@IdioticCreation
in fact I have a particle effect down, but the thing is..it is the most boring effect ever!
The colors are "plain", as in I it chooses a random colorR,colorG,colorB but it doesn't "glint" or "sparkle" or "twinkle" lol I think you get the point.

I would like to do stuff like that, but I don't know how to use OpenGl..
but if I was to use images, how would I do it? I have a series of images and just iterate through them?

There are a few ways in Allegro, depending on what you're using as particles.

If you're using sprite particles, I'd say just define transparency in the picture file itself. Use .png or the like, and an image editor that supports transparency. GIMP comes to mind, but I think paint.NET also supports transparency as well as being more lightweight. This allows for some complex transparency effects with minimal extra code.

Not sure if this is what you were talking about too but this is what I was referring to by Paint.NET: www.getpaint.net/

al_set_blender changes how allegro calculates the final colors for pixels on the screen, in a sense.
Learning some OpenGL would definitely help in understanding blending as well, but here's an attempt to explain what's going on.

To achieve any transparency effect, each pixel from the source (what you're drawing to the screen) has to be blended with each pixel in the destination in some way.

The docs say that the default is

Code:

al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA)

ALLEGRO_ONE as the second argument means that each pixel from your source (sprite or otherwise) is multiplied by 1. In other words, nothing changes.
ALLEGRO_INVERSE_ALPHA as the third argument means that each pixel in the destination is multiplied by 1-(alpha from source). So if source alpha=1, the destination pixels become 0, specifically RGBA = {0,0,0,0}. If source alpha=0, destination pixels don't change.

Then ALLEGRO_ADD says that those two values are added together.

----------
So let's say you're drawing a rectangle with RGBA={1,0,0,.5}.

ALLEGRO_ONE says that for each pixel in the rectangle, we multiply by 1 to prepare for blending.
ALLEGRO_INVERSE_ALPHA says that for each pixel in the destination, we multiply by [1-.5 =] .5 to prepare for blending. Multiplying by .5 gives the effect that color from the destination is being "blocked" to some degree by the source, like putting transparent plastic over an object.
Then each pixel from the source {R,G,B,A} is added to each pixel from the destination {R*.5, G*.5, B*.5, A*.5}.
The effect is a realistic blend of the two colors.
----------

Using ALLEGRO_ONE for both source and destination means that no change is made for either source or destination pixels. The final computation is source {R,G,B,A} + destination {R,G,B,A} meaning that colors are added together without change. No color is "blocked" by overlapping shapes, creating bright spots in areas that overlap. The result is similar to spotlights shining on a wall.

oh wow, yeah i think I sort of get it..
so I guess I have no to do this calculations myself.
the parameter doesn't say where to put the r,g,b values. So I would have to know what it is and provide the values?

Code:

void al_set_blender(int op, int src, int dst)

so if the source rectangle pixels is (255,0,0) the src is 255?
and if dest is (0,0,1) the dest is 1? I am not sure as to how to add the r,g,b values