First of all, the last elif statement wasn't necessary.
As when 'count' reaches 20, it will be reset to 0. The second if statement is for when 'count' is somewhere between 10 to 19. Therefore, you can clearly let dy = -1
outside of all the if/else statement because 'count' will always in between 0-9, if it does not meet the bool of the if statements.
Secondly, x <= 10
means that the range contains 10 numbers, while 20 > x > 10
only contains 8 numbers. Because of that, the likelihood of dy = -1
is more than dy = 1
. That's why your fish and bubble slowly move outside of the window as dx and dy (respectively) have more chances of becoming negative over time.
Solution: On the second if statement, 'count' should be equal to 10 while the third statement shouldn't.
Thirdly, it seems to be an indentation error when you paste the code. Both the if statements don't relate to each other so you can dedent the second if statement.