Tile Map Code

SGDK only sub forum

Moderator: Stef

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Tile Map Code

Post by Sik » Fri Jan 12, 2018 2:41 pm

Yukiko wrote:
Fri Jan 12, 2018 1:36 pm
What the protagonist sees is in the view port to the left. The box to the right will show the protagonist, and what is behind the protagonist. Both views are on the same plane. If I try sliding I'd wipe out the rear view. The HUD is on another plane. I don't want to turn the HUD into a sprite as I'm already bumping the sprite limit.
Erm... can't the box at the right go in the same plane as the box at the bottom?

Also there's the window plane.
Sik is pronounced as "seek", not as "sick".

Yukiko
Interested
Posts: 14
Joined: Sat Nov 18, 2017 9:33 am

Re: Tile Map Code

Post by Yukiko » Tue Jan 16, 2018 12:08 am

Sik wrote:
Fri Jan 12, 2018 2:41 pm
Yukiko wrote:
Fri Jan 12, 2018 1:36 pm
What the protagonist sees is in the view port to the left. The box to the right will show the protagonist, and what is behind the protagonist. Both views are on the same plane. If I try sliding I'd wipe out the rear view. The HUD is on another plane. I don't want to turn the HUD into a sprite as I'm already bumping the sprite limit.
Erm... can't the box at the right go in the same plane as the box at the bottom?
The box on the right is on the same plane as the box on the bottom. Inside that box goes the rear view tiles.
Sik wrote:
Fri Jan 12, 2018 2:41 pm
Also there's the window plane.
I don't get the window plane. It would be fantastic if I could slap it in the middle of the screen and have it's contents scroll without interfering with the surroundings. It sounds like the window plane is just a section of PLAN_A with a different tileset.

I tried to use VDP_loadTileSet when all the tiles are detected, and VDP_drawImageEx when they all aren't.

Code: Select all

VDP_loadTileSet(background_sewing_2_2_0001.tileset, TILE_USERINDEX+10+(bg_row*1)+(CHATBOXy*bg_row), FALSE);
if (background_sewing_2_2_0001.tileset -> numTile < CHATBOXy+1) {
VDP_drawImageEx(PLAN_B, &background_sewing_2_2_0001, TILE_ATTR_FULL(PAL3, FALSE, FALSE, FALSE, TILE_USERINDEX+10+(bg_row*1)+(CHATBOXy*bg_row)), BGx-1+bg_row, BGy+pal_offset+ntsc_offset, FALSE, TRUE);
}

Code: Select all

if (background_sewing_2_2_0160.tileset -> numTile < CHATBOXy+1) {
VDP_drawImageEx(PLAN_B, &background_sewing_2_2_0160, TILE_ATTR_FULL(PAL3, FALSE, FALSE, FALSE, TILE_USERINDEX+10+(bg_row*1)+(CHATBOXy*bg_row)), BGx-1+bg_row, BGy+pal_offset+ntsc_offset, FALSE, TRUE);
} else {
VDP_loadTileSet(background_sewing_2_2_0160.tileset, TILE_USERINDEX+10+(bg_row*1)+(CHATBOXy*bg_row), FALSE);
}
It failed miserably. I'm guessing my condition is wrong.

Moving forward I'll try scrolling it. The left view will be on the PLAN_A and will scroll. The rear view on the right will use VDP_drawImageEx on PLAN_A (the bit where it overlaps with the left view scroll will be on PLAN_B). The left side of the HUD will be converted to a sprite.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Tile Map Code

Post by Sik » Tue Jan 16, 2018 2:08 pm

Yukiko wrote:
Tue Jan 16, 2018 12:08 am
Sik wrote:
Fri Jan 12, 2018 2:41 pm
Yukiko wrote:
Fri Jan 12, 2018 1:36 pm
What the protagonist sees is in the view port to the left. The box to the right will show the protagonist, and what is behind the protagonist. Both views are on the same plane. If I try sliding I'd wipe out the rear view. The HUD is on another plane. I don't want to turn the HUD into a sprite as I'm already bumping the sprite limit.
Erm... can't the box at the right go in the same plane as the box at the bottom?
The box on the right is on the same plane as the box on the bottom. Inside that box goes the rear view tiles.
But you just said both views are on the same plane (・ω・;)
Yukiko wrote:
Tue Jan 16, 2018 12:08 am
I don't get the window plane. It would be fantastic if I could slap it in the middle of the screen and have it's contents scroll without interfering with the surroundings. It sounds like the window plane is just a section of PLAN_A with a different tileset.
It overrides plane A where it shows up. Window plane has its own tilemap, and unlike plane A it doesn't scroll. Note that window plane will do the overriding even if tiles are transparents, so you can use it to clip plane A to a side of the screen (plane B is not affected).
Sik is pronounced as "seek", not as "sick".

Yukiko
Interested
Posts: 14
Joined: Sat Nov 18, 2017 9:33 am

Re: Tile Map Code

Post by Yukiko » Wed Jan 17, 2018 3:53 am

Sik wrote:
Tue Jan 16, 2018 2:08 pm
But you just said both views are on the same plane (・ω・;)
Both backdrop views are on the same plane. Both HUD boxes are on the same plane.
Sik wrote:
Tue Jan 16, 2018 2:08 pm
It overrides plane A where it shows up. Window plane has its own tilemap, and unlike plane A it doesn't scroll. Note that window plane will do the overriding even if tiles are transparents, so you can use it to clip plane A to a side of the screen (plane B is not affected).
Great, I understand how I can use it now. I'll put the right HUD in the window plane so the scrolling backdrop on the right won't interfere with it.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Tile Map Code

Post by Sik » Wed Jan 17, 2018 4:29 pm

Given the shape of the HUD, you could just put it as a whole in the window plane (if you set both the horizontal and vertical divisions, then plane A will only show up in one of the resulting boxes, which matches the shape you have here). That also would mean both planes are free for the background (you can even scroll them vertically without needing to resort to raster effects).

In case you wonder how the split screen in that video works:
  • Plane A has the tilemap on the left
  • Plane B has the tilemap on the right
  • Window plane covers the right side and is full of transparent tiles
  • Plane A has no transparent parts (so plane B never shows through)
  • Plane A is always higher priority than plane B (for the same reason)
The division in the middle exists only to cover sprites as they cross the boundary. I can slice sprites vertically (my manipulating their size) but I'm still stuck to 8px granurality, so I need a division (also made out of sprites) that's at least 8px wide to cover that up. If you don't have sprites that can cross the boundary then you don't need that division.

EDIT: in your case you'd of course put the HUD as usual in the window plane and use transparent areas to let plane B show under it (while not letting plane A interfere).
Sik is pronounced as "seek", not as "sick".

Post Reply