I implemented a camera with edges in 2D side scrolling game using Pygame, it is working but sometimes it will scroll for more than it should have, and in case of using different moves that involved movement, sometimes the value will be in float number and it will cause the level to be buggy. I have tried different methods of camera, but none of them worked for me so far. Is there any other way to implement camera, or at least make this one work as intended?
Below is the code for scrolling at x-axis:
if self.rect.right >= 500 and self.in_level.world_shift_x >= -((self.in_level.total_level_width - (Screen_Width + 32))): diff = self.rect.right - 500 self.rect.right = 500 self.in_level.shift_world_x(round(-diff, 0)) if self.rect.left <= 200 and self.in_level.world_shift_x <= -((self.speed / 2)): diff = 200 - self.rect.left self.rect.left = 200 self.in_level.shift_world_x(round(diff, 0))