I have a large map that a player will navigate over. Currently, it is just a single background image, but I would like to make it tiled map. How do I properly keep track of player coordinates?
Currently what I have working is:
1) I have a 800px wide by 500px high playing area 2) The player is normally positioned in the center of the screen at approximately (400px x 250px) 3) When the arrow keys are pressed instead of the player moving the map moves. I am currently using background-position at the moment to set which area of a background is displayed.
What I am currently trying to wrap my head around:
4) When the map reaches the boundaries it will no longer scroll, but my player is stuck in the center. 5) How to get the player back to the center again when they start to travel away from the corners.
The main problem I am having is knowing what coordinates I should be keeping track of. For example, should I be keeping track on only one of the following, or all three of the following:
- Player position in map
- Map position on screen
- Player position on screen
What is a standard way to handle player movement like this?