For my alevel coursework I am making a game using pygame. I have come into a problem where on the left side and the top prevent my sprite passing the boarder but for the right side and bottom when I go past that barrier the sprite appears on the opposite edge. I hope that makes sense. Here is the code that I currently have for this section. x1 and y1 are for my first sprite's coordinates and x2 and y2 are for my second.
if x1 > WIDTH - Char1WIDTH or x1 < 0:
x1 = 0
if y1 > HEIGHT - Char1HEIGHT or y1 <0:
y1 = 0
if x2 > WIDTH - Char2WIDTH or x2 < 0:
x2 = 0
if y2 > HEIGHT - Char2HEIGHT or y2 <0:
y2 = 0