You tried to cram too much stuff into one if
statement in test_collide_bottom_ball
and that made debugging much harder. Its also easier in this case to consider all the reasons not to self.dy *= -1
over the reasons you should. That switching of directions is a privilege paddle and should only happen on special occasions.
I have left my debugging code in to clarify the way i thought about the problem, also there is still another bug which can get the ball stuck in the paddle, but you should be able to fix that given a similar approach. Please see the following code:
def test_collide_bottom_ball(self, coll_height, paddle):
print paddle.x, paddle.width + paddle.x, self.x
# shoot ball back to top when it has gone off the bottom
if self.y > 600:
self.y = 300
return
# ignore when the ball is far from the y access of the paddle
if not self.y >= coll_height - self.radius - (600 - paddle.y):
return
# check that the current x plus raidus to find "too small" condition
if self.x + self.radius <= paddle.x:
print "self.x too small"
return
# for too big we have to consider the paddle width
if self.x >= paddle.x + paddle.width:
print "self.x too big"
return
# ok, looks like its time to switch directions!
self.dy *= -1
P.S. use the pep8
coding standard utility. Its not any harder to code following pep8
and will save you headache.