Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprite background color
#1
I'm making a little game where the player sprite's background color is black, that means where the bitmap isn't used for the actual character it's set to black. I've got some floor/door sprites, and their background colors aren't black. So when you move your player over them you can see the black background of the player sprite. Is there any way to prevent this?

If you don't understand what I mean please tell me
Reply
#2
You use a mask, or a graphical library. To use a mask, you need another sprite of the same size as your normal sprite, and this new sprite should contain only pixels 255 and 0. For each non-zero pixel in your normal sprite, your mask sprite should have a 0, and for each zero sprite in your normal sprite, your mask sprite should have a 255. To PUT them properly, first you PUT the mask sprite using AND and then PUT the normal sprite using OR (I think that's the way it goes, it's been a few years since I've had to do this). Make sure your normal sprite uses zero (not just black, remember that the palette can make any of the 256 entries any color, and by default, both 0 and 16 are black) for its transparent areas.
I'd knock on wood, but my desk is particle board.
Reply
#3
I've got a mask already, but I didn't make the normal colors black (only the black ones 255). So I'll try that out tonight and post if it works Smile
Reply
#4
[EDIT] Nevermind I got it, like you said: first the mask then the player. Thanks Smile [/EDIT]

I did what you told me, but it wont work. In fact, the sprite gets a kind of green/black color while it's intended to be yellow :-? Here are the bitmaps and the code I display them with:

Player:

[syntax="qbasic"]

DATA 00,00,00,00,43,43,43,43,43,43,43,00,00,00,00
DATA 00,00,43,43,43,43,43,43,43,43,43,43,43,00,00
DATA 00,43,43,43,43,43,43,43,43,43,43,43,43,43,00
DATA 00,00,43,00,00,00,43,43,43,00,00,00,43,00,00
DATA 43,43,00,00,00,00,00,00,00,00,00,00,00,43,43
DATA 43,43,43,00,00,00,43,43,43,00,00,00,43,43,43
DATA 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43
DATA 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43
DATA 43,43,43,43,43,43,43,43,43,43,43,43,43,43,43
DATA 00,43,43,15,15,15,15,15,15,15,15,15,43,43,00
DATA 00,43,43,43,15,15,15,15,15,15,15,43,43,43,00
DATA 00,00,43,43,43,43,43,43,43,43,43,43,43,00,00
DATA 00,00,00,00,43,43,43,43,43,43,43,00,00,00,00
[/syntax]

Mask:

[syntax="qbasic"]
DATA 255,255,255,255,00,00,00,00,00,00,00,255,255,255,255
DATA 255,255,00,00,00,00,00,00,00,00,00,00,00,255,255
DATA 255,00,00,00,00,00,00,00,00,00,00,00,00,00,255
DATA 255,255,00,255,255,255,00,00,00,255,255,255,00,255,255
DATA 00,00,255,255,255,255,255,255,255,255,255,255,255,00,00
DATA 00,00,00,255,255,255,00,00,00,255,255,255,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 255,00,00,00,00,00,00,00,00,00,00,00,00,00,255
DATA 255,00,00,00,00,00,00,00,00,00,00,00,00,00,255
DATA 255,255,00,00,00,00,00,00,00,00,00,00,00,255,255
DATA 255,255,255,255,00,00,00,00,00,00,00,255,255,255,255
[/syntax]

Code:

[syntax="qbasic"]
PUT (PlayerX% * 15 - 15, PlayerY% * 13 - 13), Player, AND
PUT (PlayerX% * 15 - 15, PlayerY% * 13 - 13), PlayerMask, OR
[/syntax]
Reply
#5
SuperPUT!!! :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)