Ruin0x11 / OpenNefia

(Archived) Moddable engine reimplementation of the Japanese roguelike Elona.
MIT License
116 stars 18 forks source link

Making screen scrolling compatible with draw layers #356

Closed Ruin0x11 closed 3 years ago

Ruin0x11 commented 3 years ago

The current implementation of scrolling isn't very compatible with draw layers that depend on the position of game entities. The primary example of this is target_overlay, which only updates the positions of the targeting lines after the scrolling has finished. That's because the screen-space coordinates that target_overlay's draw layer calculates are based on the tile-space coordinates of the entity only, without the scrolling offset added.

We might have to expose IMapObject:get_screen_pos() or similar, which adds together the tile-to-screen, offset, and scrolling offset of the entity to get a final screen-space coordinate for that entity. The difference between the three is:

The scroll offset is not currently a property contained on map objects; it is internal to the batching indices inside the chip rendering layer at a lower level. This change would mean exposing it at a higher level somehow, so mods can always calculate the exact screen-space position of an entity after all offsets are added.