(SOLVED)Walk behind top of the walls like Crystalis.

Hi, I am working on a adventure game and it is very slow progress. My player character is 24 pixel height. When my character walk up and stop by a stone wall, it looks like my character standing against the stone wall and It look prefect. Top wall using 1-solid setting. When my character walk down until stop by another stone wall, it looks like my character standing by one tile away from a stone wall. I tried top of bottom wall as 0-Walkable setting, it look like my character walking on top of the walls. I don't like this. I tried 2-Walk behind setting on top of bottom wall, I don't want my character disappeared when it touch top of the bottom walls. So I need help on the script, that allowed the character and monsters walkable to the tiles, but keep the tiles on top of them. (Character and monster's 16 out of 24 pixel hidden behind a wall) So it look like they are closer to behind a wall but still see their heads. (8 out of 24 pixel showing) I am sure I seen that from Crystalis. If the script is too complex coding, I can set bottom of the wall 1 solid setting and move on. Thanks.
 

jorotroid

Member
It is a somewhat complex thing to do and would require some coding. Off the top of my head, I know that Silver Island had some sprites that went behind the background so you could try searching the forums to see if the creator of that game wrote up anything on how he did it.

That said, here is some general info on how it would work. Sprites have a bit that tells the PPU to either draw it behind or in front of the background. When behind the background, sprites will be covered up by all background pixels that are not the main background color. What you would need to do is have some way of telling when a sprite is going behind something to flip that bit, and then flip it again when the sprite comes out from behind it so your character doesn't look like it behind everything from then on. If your general ground tiles are just the main background color, they you can probably get away with making your entire metasprite go behind the background. But if you have any detail on your background tiles, then you will need to write code to specifically flip the background bit on just the sprites of your metasprite that will be going behind the background. Going with more detailed background tiles would probably make it unavoidable to have some graphical glitches of either part of your sprite appearing behind background ground tiles or partially in front of wall tiles at times.
 
I played Silver Island until I saw there was a tree that both of the player and monsters walk behind the tree trunk. This is exactly what I need to find a script coding for my main character and monsters walk behind the walls. Thanks jorotroid! I will talk to creator of Silver Island.
 

dale_coop

Moderator
Staff member
Silver Island uses the default "walk behind" tile (the WalkBehind.asm tile script is located in the "Routines\Basic\ModuleScripts\TileScripts\Adventure" folder... assign that script to an unused "Tile Collision xx" in your "Project Settings > Script Settings" and you can do the same).
 

CutterCross

Active member
dale_coop said:
Silver Island uses the default "walk behind" tile (the WalkBehind.asm tile script is located in the "Routines\Basic\ModuleScripts\TileScripts\Adventure" folder... assign that script to an unused "Tile Collision xx" in your "Project Settings > Script Settings" and you can do the same).

Wait, why am I only finding out about this now?! I feel like this should have been a more emphasized thing in the past.
 

jorotroid

Member
dale_coop said:
Silver Island uses the default "walk behind" tile (the WalkBehind.asm tile script is located in the "Routines\Basic\ModuleScripts\TileScripts\Adventure" folder... assign that script to an unused "Tile Collision xx" in your "Project Settings > Script Settings" and you can do the same).

Oh, wow. I never noticed that script either. Thanks for pointing it out, Coop.
 
Guess what... I did it! https://youtu.be/VsTJg2XP9-o

I was trying to figure out how WalkBehind.asm work, after several tried, I realized the first color of Sub for the tile (Top Left) is the only color stay behind the character. The rest of the colors (Top Right, Bottom Left and Bottom Right) cover up the character. I ran into quiet a bit of graphic bugs and I spend at least 7 hours to fixes all the graphic bugs and add one new script to fixed a last bug. Boy, it was frustrated, but I am soo glad it all fixed for adventure game.
 

dale_coop

Moderator
Staff member
CutterCross said:
n8bit said:
WOAH! Why are we all just now finding out about this?!?

I feel like this should have been at least mentioned in the tutorial videos or something.

Haha ;)
I think it has been mentioned in one video about the adventure module (one video from the 4.0)
 

dale_coop

Moderator
Staff member
Gregg Richardson said:
Guess what... I did it!

I was trying to figure out how WalkBehind.asm work, after several tried, I realized the first color of Sub for the tile (Top Left) is the only color stay behind the character. The rest of the colors (Top Right, Bottom Left and Bottom Right) cover up the character. I ran into quiet a bit of graphic bugs and I spend at least 7 hours to fixes all the graphic bugs and add one new script to fixed a last bug. Boy, it was frustrated, but I am soo glad it all fixed for adventure game.

It looks awesome, man!
 

Icon-Ninja

New member
Late to the party on this, but does the WalkBehind.asm work with v4.5.2? I copied it into my tile type scripts, but it's throwing an "unknown label" warning at me and refusing to compile. I'm probably missing additional module scripts somewhere, though (been away from NESMaker for a while because of work, so I've been trying to ramp back up the last couple of weeks, still going through the "summer camp" tutorials)...
 

mouse spirit

Well-known member
Id say no.It wont simply translate to 4.5 But it may only take small alterations. Can you share the code?
And if you havnt shared code before, use the Full Editor and preview, copy and paste your code,select all of it,
and then press the </> icon near the top of the page.

Code:
It'll then look like this.
Just sayin, incase you havnt posted code before
 

voltopt

Member
I've been looking into this for 4.5.2 as well, along with palette cycling.

The code in 4.1.5

Code:
	LDA Object_state_flags,x
	ORA #%00100000
	STA Object_state_flags,x

Looking through 4.5.2, it looks like Object_state_flags is ObjectUpdateByte, maybe? I don't know! I tried this, loaded the script and created and assigned the tile, but nothing happened (it did compile, though)

Code:
	LDA ObjectUpdateByte
	ORA #%00100000
	STA ObjectUpdateByte
 

mouse spirit

Well-known member
Well the walk behind script involved with that flag may not even exist in 4.5 yet is another issue. Sorry if i jumped ahead there.
 

voltopt

Member
Maybe it doesn't, I'm just tooling around trying to map program flow in 4.5.2. Since I am unfamiliar with 4.5.1, it's kind of fun. I don't have a preconceived notion.
 

CutterCross

Active member
mouse spirit said:
Well the walk behind script involved with that flag may not even exist in 4.5 yet is another issue. Sorry if i jumped ahead there.
This implementation with the Object_state_flags byte seems to control the 3rd byte of each hardware sprite in an object. So that's likely the connection that's missing in 4.5, if we're not overlooking something.

On a hardware level, the "walk behind" bit (which is actually called the priority bit) is bit 5 of byte 2 of every sprite (indexes starting at 0). Each hardware sprite holds 4 bytes, so that's the 3rd byte of the sprite data, which also handles attributes and horizontal / vertical flipping: https://wiki.nesdev.com/w/index.php/PPU_OAM
 

voltopt

Member
Right, it appears the priority bit isn't elsewhere in the beta code yet. Digging around turned up specifics for tiles and animations directly related to the limited tutorials. I can't wait to dig into the full code later this week.
 
Top Bottom