The problem, is in your handle_collision
method.
The short story:
The first thing the function does, is set dx and dy to the current vector. Then it calls reinit()
. Then, it sets them back to what the first were at the end of the function.
To fix:
Change
def handle_collision(self):
(dx, dy) = self.vector.get_xy() # <-- It first sets (dx, dy) to the old vector
if not self.area.contains(self.rect):
if self.__hit_topbottom():
...
elif self.__hit_leftright():
... # <-- here is where the reinit gets called, which changes the vector to new values.
else:
for paddle in self.hit_paddle(dx):
...
self.vector = Vec2D.Vec2D(dx, dy) # <-- Then the vector gets changed again, to the OLD vector saved above in (dx, dy)
To
def handle_collision(self):
(dx, dy) = self.vector.get_xy()
if not self.area.contains(self.rect):
if self.__hit_topbottom():
...
elif self.__hit_leftright():
...
return # <-- With the return here, the parsing never gets to change it back
else:
for paddle in self.hit_paddle(dx):
...
self.vector = Vec2D.Vec2D(dx, dy)
This will prevent the vector getting set back to what it was, while still setting it when it needs to be.