Jump to content
  • Advertisement

Archived

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

_SKOTTIE_

sprite flashing? SDL?

This topic is 5477 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

im usuing SDL for a top down shooter. when the enemy gets hit or the player gets hit, i want the sprite to flash red kinda like in arcade games. i dont want to have to write animations and create pictures for this. is there any way to edit the pallete or something to get this flashing effect? (SDL) thanks!

Share this post


Link to post
Share on other sites
Advertisement
In a few SDL shoot-em-ups, I''ve done something like this:


if(Flashing){
if(SDL_GetTicks()%500>250){
DrawSprite(imgid,x,y);
}else{
// Do nothing (so it''ll not be shown)
// or draw a reddened version.
}

}else{
DrawSprite(imgid,x,y);
}

Share this post


Link to post
Share on other sites
I don''t know if you can do that with SDL. If you''re in 256-color mode, it should be fairly simple (run through on one loop and set all colors to high red, then on the next return it to the standard palette) but I don''t know how you could do it with a 32-bit color scheme.

Share this post


Link to post
Share on other sites
You''re best bet in a mode other than 256 color would probably be to perform a pre-processing pass on the sprite, and generate another surface containing red pixels wherever there are non-transparent pixels in the source image.

In 256 color, you could set every index entry that the sprite uses to the color red, but this is bad if other parts of the scene (landscape, other characters, etc...) use those same entries, as they will also flash red. So, a pre-generated "flash frame" would probably be your best bet here, too.

This method is trivial, and wouldn''t require any extra frames to be drawn by hand. Just load in the frame as usual, create another frame of equal dimensions, and fill it with red wherever there is a pixel in the source frame. Fill the remaining pixels with your transparent color (if using color-keying). Whenever a flash is needed, draw this frame.

Josh
vertexnormal AT linuxmail DOT org


Check out Golem at:
My cheapass website

Share this post


Link to post
Share on other sites
Well, check my (in project) Shoot-em-up (demo for windows only):

http://seb.sevilla.free.fr/explode/explode15.rar

And contact me if you want the source of the "blinking" effect (SDL + 8bits-Graphics for the sprite)


------------------------
- Seby -
www.dfhi-bomber.fr.st

[edited by - theSeby on September 24, 2003 3:28:32 AM]

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!