python – Collision detection not working when camera following player

My collision detection worked before when the camera angle was fixed. But I just changed it to follow the player, and now the player walks right through the trees.

I tried to set the collision rects to have the offset in them, but it just created a large value for the coordinates. I think the issue is in this renderOver function that I’m using to pseudo depth sort my trees.

My collision detection is in the main file is_collision. I’m not sure what to do at this point. I know the collision rects are wrong, but I’m not sure how to fix them.

def renderOver(self,screen,iso_camera,movementDetected):
    for index, img in enumerate(self.objects(1)('image')):

        surfToBlit = screen.blit(img,(self.objects(1)('coordinates')(index).x-iso_camera.x, self.objects(1)('coordinates')(index).y-iso_camera.y))
        if (self.enableCollideBoxes == True):
            #print('self.previous_iso_camera: ',self.previous_iso_camera)
            #print('iso_camera: ',iso_camera)
            if (movementDetected and self.previous_iso_camera != iso_camera):
                print('Are we going here?',flush=True)
                #self.rect(index).x = self.rect(index).x+iso_camera.x
                #self.rect(index).y = self.rect(index).y+iso_camera.y
            pygame.draw.rect(self.objects(1)('dispCollideBox')(index),(0, 100, 255),(0,0,self.treeSize.w,self.treeSize.h),2)
            blitRect = screen.blit(self.objects(1)('dispCollideBox')(index),
                                   )#(self.objects(layer)('coordinates')(index).x, self.objects(layer)('coordinates')(index).y))
            #print('blitRect: ',blitRect,flush=True)
            #self.rect(index) = blitRect
            print('x-dist: ',self.rect(0).x-iso_camera.x,'y-dist:',self.rect(0).y-iso_camera.y,flush=True)
            self.previous_iso_camera.x = iso_camera.x
            self.previous_iso_camera.y = iso_camera.y
    return self.blitRect 

If you want to run the full code, you could run it here from my repo:

Just run the file. Any suggestions would be appreciated!