A89: Re: Sprite masking


[Prev][Index][Thread]

A89: Re: Sprite masking




> Ok, I just am lost when it comes to sprite masking. How? What is this mask?
> lets say I have a 8x8 sprite that is this:
> 00000000
> 00XXXX00
> 00X00X00
> 00XXXX00
> 000XX000
> 00X00X00
> 0X0000X0
> 0X0000X0
>
> Then what is it's mask?

It can be whatever you want it to be.

> Also to make sure I am clear on this, the purpose is to not have the
> background show through the sprite, correct?

Sort of. The mask determines what bits of the background you put the sprite over
will be affected (or not affected, depending on the sprite routine).
Say you want to put your sprite (the one above) on top of some background
graphic, always with a white edge around it, then the mask might look something
like this:

00xxxx00
0xxxxxx0
0xxxxxx0
0xxxxxx0
00xxxx00
0xxxxxx0
xxx00xxx
xxx00xxx
0x0000x0

So if your graphic was placed over a black background with this mask, the result
might look like this:

xxxxxxxxxx
xxx0000xxx
xx0xxxx0xx
xx0x00x0xx
xx0xxxx0xx
xxx0xx0xxx
xx0x00x0xx
x0x0xx0x0x
x0x0xx0x0x
xx0xxxx0xx
xxxxxxxxxx

Think of it like this: you have a background graphic, say a postcard. Then you
have a sprite (a photo of yourself). You want to paste that photo over the
postcard, so you cut away everything but yourself from the photo. The stuff you
cut away is then the mask, in that wherever that part of the photo was you want
the postcard to show through.

--
 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF v5.1 Quote follows:

People who didn't need people needed people around to know that they were
the kind of people who didn't need people.
        -- (Terry Pratchett, Maskerade)





References: