The reason the sprites sometimes become immobile after colliding is because of this code here:
pacman_velocity[0] = randint(-1,1)
pacman_velocity[1] = randint(-1,1)
randint for that range means you're getting an integer value that is either -1, 0, or 1.
From the docs: (http://docs.python.org/2/library/random.html)
random.randint(a, b)
Return a random integer N such that a <= N <= b
That means that (theoretically) each time there is a collision, there is a 1/3 chance that the x component of the velocity will be 0, and a 1/3 chance that the y component of the velocity will be zero. If you only want to select either 1 or -1, try the random.choice() function:
pacman_velocity[0] = random.choice((-1, 1))
pacman_velocity[1] = random.choice((-1, 1))
If you wanted to include 0 as a possibility, but want to reduce its frequency, you could accomplish that with something like this:
pacman_velocity[0] = random.choice((-1, -1, -1, 0, 1, 1, 1))
pacman_velocity[0] = random.choice((-1, -1, -1, 0, 1, 1, 1))
The problem with this loop you tried:
For sprite in sprite_list():
sprite.left < 0 or sprite.right > WIDTH:
sprite_velocity[1] = -1 * sprite_velocity[1]
is that you are checking to see if the sprite has passed the left or right boundary of the screen, but then instead of reversing the x component of the sprite's velocity, you are reversing the y component of the velocity. Also, you don't have an if
at the beginning of the condition. Try this:
For sprite in sprite_list:
if sprite.left < 0 or sprite.right > WIDTH:
sprite_velocity[0] = -1 * sprite_velocity[0]
if sprite.top < 0 or sprite.bottom > HEIGHT:
sprite_velocity[1] = -1 * sprite_velocity[1]