I have this problem where I split my big world into chunks and I don't know how to draw it into my game camera's view. Each world chunk has its own coordinate system, so when object reaches border of one chunk and steps into another - coordinate system resets to zero. For example from world_x = 1440 into world_x = 0.
To draw only those objects that are in the camera's view, I use code:
int screenX, screenY; //screen position of the object being drawn
screenX = object.x-camera.x;
screenY = object.y-camera.y;
The problem appears when camera sees two different chunks. Lets say camera's coordinates are:
screenX = 567
screenY = 0
My drawable object is at
world_x = 1266
world_y = 0
In this case object's screen coordinates are (x)699, because screenX = object.x-camera.x. But what if camera stays in the same place and object finally reaches different chunk. Object's coordinates are reset to zero. That means that its screen coordinates becomes (x)-567.
That screen coordinates conversion would work if I would be doing non partitioned game world, but now it don't. Any ideas?