I am going to work on my next game project, however there are some issues I want to correct since my last one. Here is one of them:
This is a problem I think I can already solve, but I'd like to hear any criticisms on said solution, and perhaps hear other solutions that may exist.
The problem:
I have a window 800W by 600H, and my player's position is stored as pixels down, and pixels right. Lets say this player can run to the edge of the screen. This works fine until someone say, changes the size of the window, thus the player can run further out, where he should not be. In one of my first game attempts (a TD), enemies were dependent on the pixel position of game objects (Tiles), and thus by resizing the window, they ended up wandering off path.
A solution:
Represent the world with boundaries placed at 0 and 1 (or any other numerical pairing), and place entities as a percentage across. e.g. Player.positionX = 0.5, would mean that the player is half way across the map. Perhaps instead of 0, 1, it was 0, 1000 instead? With floating/double error in mind, what choice might I make?
So I think that would work fine in most cases, do you think so? What is a typical approach? What other approaches exist? How might platform/game type affect this choice? What if for some reason, the world size were to change dynamically? (Odd, but I'll throw it in there)