Page 1 of 1

Tilemap Collision and Sprite Sorting Demo

Posted: Mon Apr 08, 2019 3:26 pm
by hotrodx
It's not much, but this is my progress learning SGDK.

I'm mainly using IMAGE for the tile mapping. Added some stuff Stef suggested on another thread regarding collisions, also using IMAGE but not uploaded to VDP.

Then some sprite/background sorting (which one is front or behind).

There's still much to learn. Hopefully I'll get there someday.

Re: Tilemap Collision and Sprite Sorting Demo

Posted: Tue Apr 09, 2019 7:26 pm
by SegaTim
It looks very good. Will you create jRPG?

Can you give Sprite Sorting code?

Re: Tilemap Collision and Sprite Sorting Demo

Posted: Wed Apr 10, 2019 2:47 am
by hotrodx
SegaTim wrote:
Tue Apr 09, 2019 7:26 pm
It looks very good. Will you create jRPG?

Can you give Sprite Sorting code?
I'd like to do an RPG someday, but using original material. I just used Phantasy Star for the demo.

As for sprite-to-sprite sorting, I used SPR_setDepth, using the negated Y value. So if we have something like:

Code: Select all

SPR_setPosition(sprite, fix32ToInt(posX), fix32ToInt(posY));
then the depth should be something like:

Code: Select all

SPR_setDepth(sprite, -fix32ToInt(posY));
As for sorting between sprites and backgrounds, I used overlays in the second plane. You can see how it's done by using the Plane Viewer in Gens KMod. It's sufficient to create "depth" as sprites walk around a building.

It's a bit different with the original Phantasy Star II, as I think it used individual priority bits on tiles. Whole buildings belong to the second plane, but certain tiles are over the character sprites. I can't figure out how to embed such information onto an image, unless I do another separate IMAGE resource dedicated to priority bit like I did with collisions.