Tilemap Collision and Sprite Sorting Demo

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Post Reply
hotrodx
Very interested
Posts: 50
Joined: Thu Mar 21, 2019 1:23 pm

Tilemap Collision and Sprite Sorting Demo

Post by hotrodx » Mon Apr 08, 2019 3:26 pm

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.
Attachments
tilemap_collision_sprite_sorting.zip
(70.44 KiB) Downloaded 370 times

SegaTim
Very interested
Posts: 177
Joined: Thu Nov 19, 2015 1:59 pm
Location: East Prussia
Contact:

Re: Tilemap Collision and Sprite Sorting Demo

Post by SegaTim » Tue Apr 09, 2019 7:26 pm

It looks very good. Will you create jRPG?

Can you give Sprite Sorting code?

hotrodx
Very interested
Posts: 50
Joined: Thu Mar 21, 2019 1:23 pm

Re: Tilemap Collision and Sprite Sorting Demo

Post by hotrodx » Wed Apr 10, 2019 2:47 am

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.

Post Reply