Ejemplo n.º 1
0
 def reset(self):
     self.rect.center = CENTER
     self.speed = 10
     if random.random() < 0.5:
         self.orientation = Vector2.Right()
     else:
         self.orientation = Vector2.Left()
Ejemplo n.º 2
0
 def calc_bounce_angle(self, pos):
     pos = Vector2(pos)
     ball_pos = Vector2(self.ball.rect.center)
     delta = pos.y - ball_pos.y
     delta = min(delta, 55) if delta > 0 else max(delta, -55)
     if ball_pos.x < pos.x:  # Bounces on right paddle
         result = Vector2.Left()
         result.theta = pi + delta * pi / 200
     else:
         result = Vector2.Right()
         result.theta = -delta * pi / 200
     return result
Ejemplo n.º 3
0
def test_create_unitary_axis_vectors_left():
    left = Vector2.Left()
    assert left.x == -1
    assert left.y == 0