Mist around sprites!

Started by
10 comments, last by GameDev.net 17 years, 10 months ago
I am making a Breakout clone in SDL with C++, in Windows. I made some sprites for the game (paddle, ball, background). I put the paddle and ball on a magenta background (R255,G0,B255), for transparency when it is loaded into the game. When I went to test the game there was a magenta "mist" around my sprites. I assumed it was the anti-aliasing in Photoshop, so I re-detailed the sprite by zooming in and using the magenta color to erase the blurry pixels. This worked, and there was no "mist" around the sprites. However, the sprites looked crappy due to the lack of AA. So how can my sprites become AA in SDL?
Advertisement
What you're running into here is a problem that results from only having a boolean "alpha channel". Since you only have one color that is transparent, you can't have partially-transparent pixels, which means that you can't fade out your sprites. If you have a consistently-colored background, you can fade out to that color instead of to magenta, but otherwise I suspect your only feasible option is to switch to an image format (e.g. PNG) that has a range of transparency levels and to use "real" transparency in the image instead of telling SDL to treat a single color as trasparent.
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
Aye, SIR! That was quite simple. All I did was set the background to transparent in Photoshop, and now it works perfectly! But is there a way to get my colorkeys to work, without having that "mist" around the sprite?
You can create a sprite with variable levels of alpha if you use a format like PNG and load it via SDL_image.

Colourkeys don't support multiple levels of alpha.
just out of curiosity, can you post a screenie of your project?
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.
Quote:But is there a way to get my colorkeys to work, without having that "mist" around the sprite?


Nope. The way colorkeys work there is no (logical) way to make them work.

Check out my new game Smash and Dash at:

http://www.smashanddashgame.com/

Here is the mist I was talking about:http://img474.imageshack.us/img474/8297/test8eb.png

I don't have any pictures of the project, since I was just testing some stuff for now. So...What your saying is that colorkeying is not worth my time? I'll have to stick with using the transparent background in Photoshop, correct?
Colorkeying is strictly less capable than true transparency, as you can only have "on" and "off" transparency. In contrast, real transparency can allow light to filter through an image, showing what is behind the image with some of the image's color. Plus, true transparency is easier to make, since PNG files are simple beasts.

Why do you want to use color keys, anyway?
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
I thought colorkeying was the only way for transparency, I did'nt know I could use the built in transparency on paint programs. So colorkeying is outdated I guess...It's one less thing for me to worry about now!
Just use the good ol' alpha bit. Full transparancy support with much less trouble :-)
There was a saying we had in college: Those who walk into the engineering building are never quite the same when they walk out.

This topic is closed to new replies.

Advertisement