Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering order of events on the map #2816

Closed
Ghabry opened this issue Jun 25, 2022 · 1 comment
Closed

Rendering order of events on the map #2816

Ghabry opened this issue Jun 25, 2022 · 1 comment

Comments

@Ghabry
Copy link
Member

Ghabry commented Jun 25, 2022

Turns out that events that are on the same Y are rendered from right to left.

Additionally when Y + X are the same since 2k3E the Event ID decides what appears in front on the tile.

We use a single Z value for all the ordering and have now the problem that this will not really fit.

The Z-value is 32 bit and on the map is currently encoded like this:

LLLL LLLL ---- ---P DDDD DDDD DDDD DDDD

  • L = Highest bits are for the layer to ensure that drawables do not "leak" in other layers (e.g. the tilemap into the weather layer)
  • P = Bit set for pictures when they are on a layer with other things (only 2k3E)
  • D = Bits for free usage by drawables

For characters this is currently:

LLLL LLLL ---- ---P YYYY YYYY YYYY YYYY

Though to fix the rendering order we will need also storage for X and ID.

Highest X and Y (map map size of 500 * 16) is 8000. So this already needs 13 Bits for X + Y = 26 Bit.

So with some trickery this could be:

LLLL LLYY YYYY YYYY YYYX XXXX XXXX XXXX (Picture can be interleaved with L). Then this would fit but is not really future proof.


Better is maybe moving to 64 Bit (with a performance impact especially on the tilemap layers which goes through the entire map to figure out what is supposed to be drawn).

With 64 Bit we would have lots of space without trickery:

LLLL LLLL ---P ---- YYYY YYYY YYYY YYYY XXXX XXXX XXXX XXXX IIII IIII IIII IIII

So X, Y and ID can go up to 65536. So is enough for everything :).

@Ghabry Ghabry added this to the 0.7.1 milestone Jun 25, 2022
@Ghabry Ghabry self-assigned this Jun 25, 2022
@Ghabry
Copy link
Member Author

Ghabry commented Jun 26, 2022

Correction: We can delay this problem a bit for now.

Just checked the values for ScreenX and ScreenY and they are between 320 and 240 except for looping maps.

To handle looping properly the value range must be 320 * 2 and 240 * 2.

Though this is not suitable for higher resolution games then, but at least short-term this will be okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant