I understand that you want to animate your data point in a particular way such that when it disappears on one side, it reappears from the opposite side with the same velocity.
You can change the conditions of the ‘if’ statement to be such that whenever
if x_tmp>MAX_X:
x_tmp=x_tmp-MAX_x %so that it appears from the other side, without changing direction.
similarly,
if x_tmp<0:
x_tmp=MAX_x+x_tmp
And same for y_tmp as well. Additionally, x_tmp1 is an array of x_tmp so while comparing with 0 or MAX_x, you should compare with x_tmp and not x_tmp1.
I hope this resolves your query.