I’ve made it so when the sprites of player1 and player2 collide, the code stops taking input and they do not move. I’ve been having trouble implementing the movement if the input after the collision is opposite to the direction of the collision, so that when the two sprites collide they don’t overlap and can move away from eachother.
This is as far as I got on this snippet of my code:
keys1 = pygame.key.get_pressed()
if pygame.Rect.colliderect(player1.rect, player2.rect) == False:
player1.update(keys1)
else: (continue moving if input diretion is opposite to collision direction)