Sumez wrote:
You shouldn't need to do this synchronization thing for anything other than scrolling your nametables.
How do you propose we update the middle of a name table after destroying a block or collecting an item then? Characters interact with the level map and items in level space, so that's what you have, and when you need to change or erase them from the name tables you need to convert their positions into screen space, don't you?
Quote:
My biggest reason for always syncing the "nametable scroll" to the "logical scroll" value via division by 15 is that I want to be able to "spawn" the stage at any given coordinate
Totally doable with the 2 anchors approach. In fact, since there's no hardcoded relationship between the 2 separate spaces, you can start the primary anchor anywhere you want in the level, and the secondary anchor anywhere in the name tables, only the lower bits have to match, for obvious reasons. I always initialize my secondary anchor (NTCameraY) to
CameraY & 15 (since my meta tiles are 16x16 pixels), no division necessary. Just start on the first NT row every time and it works just fine.
Quote:
so I need this routine anyway, and since it's still only called once per frame as a worst case scenario, there's no real loss for only using that. Keeps my code nice and tidy.
If you think you need the division and you somehow find a division tidier than an addition (to keep 2 anchors synchronized), that's your call, but I honestly think you haven't analyzed the alternate approach in depth yet, and are simply more comfortable with what you already have.