Handmade Hero » Forums » Code » Camera coordinates or not
1 posts
#13193 Camera coordinates or not
1 year, 1 month ago

I am following the show and I am currently at episode 52 where casey starts changing the move-player code from checking against tiles to checking against entities. He wants to use the camera coordinates for this, which of course makes a lot of sense since these only change if he changes screens and are easier to work with ( i guess? ).

In the game I want to write the hero will always be in the center, so it is constantly scrolling and thus the camera coordinates of each entity would change every frame and not just on screen-change.

Now my problem is the following. Should I even bother with camera coordinates if I have to compute them every frame and they are basically just shifted tile_map_position's?
Simon Anciaux
481 posts
#13207 Camera coordinates or not
1 year, 1 month ago

If the camera is moving all the time it's probably not a good idea to base your position system on that. You can use a system of dividing the world in chunks of a certain size and having your position be the ID of the chunk (e.g. x and y integer position of the chunk) plus the position of the entity (x and y float) relative to the chunk origin.