Sign in to follow this  
Sentralia

Mist around sprites!

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Using alpha blits in SDL CAN lead to slowdown. In this case for the ball and paddle it more than likely will not make much of a difference.

That being said:

Using color keys is not "outdated" in this case as color keys have been used in pretty much every arcade version of this game and many of the ones showcased here on Gamedev use it as well. This is not a knock on your art skills (I have none to speak of) but you can usually make a decent looking ball in mspaint and you don't have to worry about it anti-aliasing your graphics like photoshop. It is more of a WYSIWYG editor (Paint.Net is rather cool as well) as far as color keys are concerned.

I do only mention this because as you use more and more sprites with SDL (alpha is done in software) you can see a noticeable slowdown.

Please note that I did mention above that slowdown will most likely not be an issue with a game like breakout.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Open the sprites in your paint program of choice and replace the edges of the sprites with the magenta color. A pixel that to you looks like it is the correct color may in fact be 255,2,251 or something similar. And since SDL only removes 255,0,255 ones the other ones will be visisble.

...Or use png files with alpha. Whatever floats your boat.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this