This was my old algorithm
def spawn(self):
self.position_move() #to adjust when the player is spawned
def position_move(self):
#gets called everytime the player moves
camera.x = -object.x+Window.size[0]/2.0
camera.y = -object.y+Window.size[1]/2.0
It worked well though when I approached a corner, I could see the ‘outside’ of the room.

The whole purpose of my updated algorithm is to prevent seeing the ‘outside’ of the room:
def spawn(self): #when the player is first spawned
self.position_move() #to adjust when the player is spawned
def position_move(self):
#camera.x = -(top left x corner of camera coordinate)
#camera.y = -(top left y corner of camera coordinate)
#room_size= total room (or world) size
diff=(object.x-Window.size[0]/2)
if diff<0:
camera.x = object.x+diff
else:
diff=(object.x+Window.size[0]/2)-room_size[0]
if diff<0:
camera.x = -object.x+Window.size[0]/2.0
diff=(object.y-Window.size[1]/2)
if diff<0:
camera.y = diff+Window.size[1]/2
else:
diff=room_size[1]-(object.y+Window.size[1]/2)
if diff>0:
camera.y = -object.y+Window.size[1]/2.0
My idea for the updated algorithm was to translate the camera back into the room by how much it is outside the room. Though my updated algorithm for some reason goes wonky sometimes (flies away, or doesn’t even follow the player).
So yeah, it is a little complicated for what I thought was a simple task. Does anyone know the error is in my algorithm?
(The framework I am using has a coordinate system like this)

Not sure what the error in your code is (I haven’t really looked), but here’s a straightforward way of bounding the camera to the world: