Author Topic: Seeing Through Sprites  (Read 7279 times)

0 Members and 1 Guest are viewing this topic.

Offline Vile Smile

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Seeing Through Sprites
« on: October 19, 2010, 10:41:30 pm »
How do I draw a sprite so that the white part of the image isn't transparent?

_player1537

  • Guest
Re: Seeing Through Sprites
« Reply #1 on: October 19, 2010, 10:42:29 pm »
I think Quibigo created the "Pt-Mask(" command for this.  Sadly, I never looked into how it works.  If you want to search the Axe Parser thread, he explained it in detail how it works.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Seeing Through Sprites
« Reply #2 on: October 19, 2010, 10:43:21 pm »
http://ourl.ca/5980
I believe Builderboy explains it pretty well. :)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Seeing Through Sprites
« Reply #3 on: October 19, 2010, 10:45:36 pm »
I think you guys might be overthinking this... I think all he wants is Pt-Off() instead of Pt-On().

_player1537

  • Guest
Re: Seeing Through Sprites
« Reply #4 on: October 19, 2010, 10:46:19 pm »
Oops lol :P  You are correct Runer112.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Seeing Through Sprites
« Reply #5 on: October 19, 2010, 10:46:52 pm »
Whoops, yup.  I believe you want Pt-On() instead of Pt-Off(). :)

_player1537

  • Guest
Re: Seeing Through Sprites
« Reply #6 on: October 19, 2010, 10:47:12 pm »
Ztrumpet, backwards.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Seeing Through Sprites
« Reply #7 on: October 19, 2010, 10:48:03 pm »
How do I draw a sprite so that the white part of the image isn't transparent?
Either I'm backwards, or the "isn't" is throwing me off. :P
« Last Edit: October 19, 2010, 10:48:19 pm by ztrumpet »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Seeing Through Sprites
« Reply #8 on: October 20, 2010, 12:34:40 am »
Are you sure, though? I think the first post might have a typo, noticing the title. I think he meant is, but I'm not sure.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Vile Smile

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: Seeing Through Sprites
« Reply #9 on: October 20, 2010, 07:17:36 am »
Sorry if I wasn't clear.

I meant a wanted certain white parts of the sprite to be solid, not just a black outline. I want to prevent backgrounds from appearing inside my player. 

ASHBAD_ALVIN

  • Guest
Re: Seeing Through Sprites
« Reply #10 on: October 20, 2010, 07:55:57 am »
with the pt-Mask(x,y,sprite) command, you can take a masked spritee and draw it on the screen so that certain parts are white, certain parts are transparent.

How a masked sprite works:  there are two parts; the normal sprite and it's back buffer sprite.  the front sprite defines what is black and what is white; then the back buffer decides what is filled white, and what is transparent.  a black dot on the front buffer is always black (in monochrome mode, no grayscale) if a dot is blank in the front buffer sprite, then if there s a pixel behind it that is black it will show up filled with the pt-mask() command.

a sprite data like this (in binary -- easier to visualize)

11000000
00001100

if the first byte is front buffer and the second is back buffer, then the first two pixels drawn will be black, the next two transparent, the next two filled white, he last two transparent.

if you still don't understand, look in the axe parser documentation for a better idea. ;)
« Last Edit: October 20, 2010, 07:57:13 am by ASHBAD_ALVIN »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Seeing Through Sprites
« Reply #11 on: October 20, 2010, 08:11:08 am »
with the pt-Mask(x,y,sprite) command, you can take a masked spritee and draw it on the screen so that certain parts are white, certain parts are transparent.

How a masked sprite works:  there are two parts; the normal sprite and it's back buffer sprite.  the front sprite defines what is black and what is white; then the back buffer decides what is filled white, and what is transparent.  a black dot on the front buffer is always black (in monochrome mode, no grayscale) if a dot is blank in the front buffer sprite, then if there s a pixel behind it that is black it will show up filled with the pt-mask() command.

a sprite data like this (in binary -- easier to visualize)

11000000
00001100

if the first byte is front buffer and the second is back buffer, then the first two pixels drawn will be black, the next two transparent, the next two filled white, he last two transparent.

if you still don't understand, look in the axe parser documentation for a better idea. ;)

Actually the Pt-Mask() command (accessible as the Plot1() token) has different logic, as it was designed for 3-level grayscale masked sprites. Each sprite would have 2 8-byte buffers of data. The bits in each byte in the buffers would correspond to a pixel color as follows:

Code: [Select]
            Second buffer
            1       0   
First   1   Black   Gray
Buffer  0   White   Transparent

ASHBAD_ALVIN

  • Guest
Re: Seeing Through Sprites
« Reply #12 on: October 20, 2010, 01:56:01 pm »
umm....

It works for monochrome as well. I tested it and it says so in the documentation as well.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Seeing Through Sprites
« Reply #13 on: October 20, 2010, 02:03:59 pm »
Yeah in monochrome you simply just have to not use any gray :P. It's also the same size as you need the second buffer for the transparency
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Seeing Through Sprites
« Reply #14 on: October 20, 2010, 02:08:43 pm »
Yes, you can use the Pt-Mask() routine for masking monochrome sprites, but you didn't quite define the logic of how things are drawn correctly. You got how to draw white and transparent pixels correctly, but black pixels need to have their corresponding bit be on in both buffers of sprite data, not just the first buffer. Having the bit on in just the first buffer was designed for gray, which turns the pixel on in the back buffer (not used in black and white displaying) but turns the pixel off in the front buffer.
« Last Edit: October 20, 2010, 02:38:44 pm by Runer112 »