This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Begginer's query: Why doesnt sprite go behind sky ?

Begginer's query: Why doesnt sprite go behind sky ?
by on (#52800)
I am currently working on a sample nes program that uses the tiles from smb1.

I created a small screen with only sky and bricks (both from smb1). Then I set the background priority in the sprites to 1(i.e. behind the background). Then I moved the sprite on the screen. It went behind the brick ok but didn't go behind the sky(the sprite was visible when I moved it on sky). Why?

by on (#52801)
Color #0 is transparent, so with the sprite drawn behind the background, the sprite will still show through any transparent pixels in the background.

by on (#52804)
Dwedit wrote:
Color #0 is transparent, so with the sprite drawn behind the background, the sprite will still show through any transparent pixels in the background.


Thanks for the quick reply! :)
So does this mean color #0 is always transparent no matter what color we have set in the current pallette? I mean If I have used some other color as color #1 in the pallette (the one which the sky uses) would it still be transparent?

by on (#52805)
The color #0 of tiles is always the transparent one, and that for both BG and sprites. The color you write at $3f00 or $3f10 is the one you see when both BG and sprites have a transparent pixel.

by on (#52812)
If you want some concept of "behind the sky": Put a gray cloud-bush in the sky, and the sprite can appear behind the cloud.

If you want to hide a sprite entirely: Set its Y coordinate to any value in the range $EF through $FF.

by on (#52828)
It's best to think of color #0 as its own plane. It's a solid color plane, that you can do vertical gradients on - if you've got the interrupts for. But just remember, nothing is shown behind that plane ;)

And the 4 layers would be (from back to front):

BG #0, sprite low priority, BG tilemap, sprite high priority.