After implementing collisions in my pygame player class, when the player collides with a wall, and the user is holding that corresponding key along with any key that makes the player move in a different axis then the play will "slingshot" across the screen. I believe this has something to do with the tile maps glitching the player off the screen but I'm not 100% certain.
The collision code is...
def colliders(self):
for tile in tile_rects:
if tile.colliderect(self.rect):
if self.speed[1] > 0:
self.rect.bottom = tile.top
elif self.speed[1] < 0:
self.rect.top = tile.bottom
if self.speed[0] > 0:
self.rect.right = tile.left
elif self.speed[0] < 0:
self.rect.left = tile.right
where tile is derived from a function above that maps the tiles to the screen and the self.rect and speed are properties of the player from the above player class.
A video example of the issue... https://www.youtube.com/watch?v=FbJAC3LulHM&ab_channel=spretzelz
Full Code... https://pastebin.pl/view/9dc1c4aa