Another question about sprites
Another question about sprites
I'm just learning about sprites and I'm a little stuck.
When I place my sprite on the screen the colours turn out all messed up.
Here's what I am doing.
I use gifload to load a gif file containg all my sprites, then I GET the sprites into my array. Next I turn the entire screen white, except for where the sprites are which I turn black.
then I GET my mask into a different array, using all the same coordinates i did for the original sprites.( i just copied and pasted the GET code and changed the array name)
Then I GIFLOAD my background, PUT the mask using AND, then PUT the sprite using XOR. According to some tutorial I read, that should work, and not affect my sprite's colours. What is wrong?
When I place my sprite on the screen the colours turn out all messed up.
Here's what I am doing.
I use gifload to load a gif file containg all my sprites, then I GET the sprites into my array. Next I turn the entire screen white, except for where the sprites are which I turn black.
then I GET my mask into a different array, using all the same coordinates i did for the original sprites.( i just copied and pasted the GET code and changed the array name)
Then I GIFLOAD my background, PUT the mask using AND, then PUT the sprite using XOR. According to some tutorial I read, that should work, and not affect my sprite's colours. What is wrong?
Sounds like you got a pretty good grasp of masking, so I won't need to orientate you on that...but one thing you need to keep in mind is that you're in a paletted mode. Whoever described masking to you neglected to mention that if the palette is different, your colors are going to change. Basically...it sounds like your sprite's palette is different than the palette of the image you're loading. They need to have the same palette. Masking isn't about making sprite colors not change...it's about allowing for sprites with transparent regions. Also, it doesn't matter if the colors of your mask are white or black...we're not dealing with an RGB mode where that method holds true. Again, you're dealing with the palette, so what you would consider black would actually have to be palette index 0, and what you would consider white would be palette index 255.
Like i said, I'm new so . .
I haven't got a grasp on pallette's yet (palette, pallete, pallette?), this is probably one of the first things i should have learned, but it isn't. I never changed the pallette. I stole all my sprites and the background from the same program(as .bmp's) and turned them all into .gif's using PSP8. Like i said, i haven't touched the pallette so that should be the same for my entire program. Also, because my program doesn't work right quite yet, i'll have to ask. Does the Mask eliminate the Black box that surrounds the sprite or is there something else to take care of that?
Re: Like i said, I'm new so . .
That is its sole purpose.o_O wrote:Does the Mask eliminate the Black box that surrounds the sprite or is there something else to take care of that?
Not it's sole purpose
it is also meant to prevent the colours from become distorted. isn't it?
Nope. That has absolutely nothing to do with it.
However, if you look at it in the sense of taking an ordinary sprite and PUTting it using the XOR operator, then yeah...I guess you could say it has to do with preserving colors.
But since that's not what you're referring to here, then nope...that is a completely unrelated subject.
However, if you look at it in the sense of taking an ordinary sprite and PUTting it using the XOR operator, then yeah...I guess you could say it has to do with preserving colors.
But since that's not what you're referring to here, then nope...that is a completely unrelated subject.
I don't know if this tutorial will be of any help, but you might want to check it out:
http://www.petesqbsite.com/sections/tut ... prite2.htm
The bottom section discusses simple sprite masking techniques.
http://www.petesqbsite.com/sections/tut ... prite2.htm
The bottom section discusses simple sprite masking techniques.
There
I uploaded the source code, and all associated files. You can find it all at
http://www.angelfire.com/games5/heliostrapolis/ It's called "A Space Quest clone, An on going project That I can't get to work." Thanx for the help.
http://www.angelfire.com/games5/heliostrapolis/ It's called "A Space Quest clone, An on going project That I can't get to work." Thanx for the help.
Okay, and again, sorry
Sorry about crashing your browser, like I said, made the site a couple years ago and never really did any major changes, just enought to keep it active(even though no one ever visits it). I just played with it a bit, I stopped the music and moved the downloads to another page.
http://www.angelfire.com/games5/heliost ... loads.html
sorry )-: But thanx for at least trying to help
http://www.angelfire.com/games5/heliost ... loads.html
sorry )-: But thanx for at least trying to help
Okay, as I said...it wouldn't take me long to discover the problem, and as I suspected, the problem is your palette. Each image has a different palette; that's a no-go when dealing with a paletted mode. Each of your images needs to be using the same colors. I've taken the liberty to create a unified palette for the three images you provided; it's not difficult at all to do, and I did it with Paint Shop Pro.
http://www.nodtveidt.net/gifs.zip
That's the reason your sprites have the wrong colors. Now, a couple of suggestions for your code:
* You should get into the habit of indenting code loops. Although it's preference, it makes it easier for others to read your code. For example:
* This is a no-no:
NEVER use hard paths. Use absolute paths. Also, you don't need to use CALL for subs that have declares. And if you don't manually write the declares in the QB IDE, the IDE will add them for you.
For the images...a great way of creating a unified palette is to take all the images you're going to need and paste them into one large image, then reduce that image to 256 colors. Save the resulting palette. Now, apply that palette (using Nearest Color) to all of your images. You'll have a perfect unified palette and never have another color problem as long as all your images use that palette.
http://www.nodtveidt.net/gifs.zip
That's the reason your sprites have the wrong colors. Now, a couple of suggestions for your code:
* You should get into the habit of indenting code loops. Although it's preference, it makes it easier for others to read your code. For example:
Code: Select all
'although this works...
IF x = 2 THEN
PUT (a, b), rog1mask(z), AND
PUT (a, b), rog1(z), XOR
ELSEIF x = -2 THEN
PUT (a, b), rog2mask(z), AND
PUT (a, b), rog2(z), XOR
ELSEIF y = 2 THEN
PUT (a, b), rog3mask(z), AND
PUT (a, b), rog3(z), XOR
ELSEIF y = -2 THEN
PUT (a, b), rog4mask(z), AND
PUT (a, b), rog4(z), XOR
END IF
'this looks better
IF x = 2 THEN
PUT (a, b), rog1mask(z), AND
PUT (a, b), rog1(z), XOR
ELSEIF x = -2 THEN
PUT (a, b), rog2mask(z), AND
PUT (a, b), rog2(z), XOR
ELSEIF y = 2 THEN
PUT (a, b), rog3mask(z), AND
PUT (a, b), rog3(z), XOR
ELSEIF y = -2 THEN
PUT (a, b), rog4mask(z), AND
PUT (a, b), rog4(z), XOR
END IF
Code: Select all
CALL gifload("c:\dos\cart.gif")
For the images...a great way of creating a unified palette is to take all the images you're going to need and paste them into one large image, then reduce that image to 256 colors. Save the resulting palette. Now, apply that palette (using Nearest Color) to all of your images. You'll have a perfect unified palette and never have another color problem as long as all your images use that palette.
Thanx
Thanks for all the help, and again sorry about the webpage. Like I said in some earlier post (if i din't say it, I should have) I'm pretty much new to sprites and images and palletes. As for the indenting of code, i usually do, but I guess i got lazy and just started typing the code. Thanx again for the help