Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ZadrraS

[SDL] Primitive 2d light effects, problems....

This topic is 5240 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to do a primitive light effect when the players gun is fired, i simply do this:
void Light() {
		SDL_SetAlpha(yellow, SDL_SRCALPHA, 80);
		Draw(yellow, xpos+20, ypos);
		
}
It blits a surface called yellow, which is simply a yellow 40x40 cube on the player, but i need it to be only on the player. I tried blitting it not onto surface "screen" but on the "player" surface, then, it works as it should, but i can''t erease it after its blitten once. What could i do?

Share this post


Link to post
Share on other sites
Advertisement
Blitting it onto the player surface keeps it on the plaeyr surface.

you''d need two player surfaces one with the effect, and one without.

and as long as you''re doing that, why not go draw a nicer looking effect on the player and laod it as the image with the gun firing?

Share this post


Link to post
Share on other sites
You're blitting it directly to the player surface which means it'll stay there because you change the pixel values in the player bitmap to erase it you'd have to reload the player image from it's file. However constantly doing that would not be a good idea. One solution would be to have another copy of the player surface you could use and overwrite the one you put the yellow square on when you want to erase it.

[edit]C-Junkie beat me to it, and I'd recomend his solution of drawing your own nicer version of the light effect[/edit]

[edited by - Monder on April 12, 2004 10:01:23 AM]

Share this post


Link to post
Share on other sites
Why not just draw it on the gamescreen directly? Just keep updating the effect for, say, 200-300 ticks, then stop. Next redraw, it''ll be gone.

Share this post


Link to post
Share on other sites
i like the idea of drawing it as a whole new sprite. You could make it much more precise and cool that way.

Share this post


Link to post
Share on other sites
no, i mean have the character_normal sprite, then a character_when_gun_fires sprite. Swap the two when your fire the gun instead of trying to overlay two graphics. It''s not very dynamic, but it would look really nice.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!