title: Python Turtle how to create collision
body: <p>I am attempting to create pong using Turtle, however, I am having an issue with the collision system. I am using a basic pythagorean function for this, however, when the ball hits a bumber, it gets stuck at the bumper and starts shaking. I am not sure how to fix this problem. Here is the collision and bumper code.</p>
  
  <pre><code>turtle.register_shape('bar.gif')
  
  lbump = turtle.Turtle()
  lbump.color('white')
  lbump.shape('bar.gif')
  lbump.penup()
  lbump.speed(0)
  lbump.setposition(-285,0)
  
  rbump = turtle.Turtle()
  rbump.color('white')
  rbump.shape('bar.gif')
  rbump.penup()
  rbump.speed(0)
  rbump.setposition(285,0)
  
  ball = turtle.Turtle()
  ball.color('white')
  ball.shape('circle')
  ball.penup()
  ball.speed(0)
  ball.setposition(0,0)
  ballspeedx = -5
  ballspeedy = 0 #To test collison#
  
  def isCollision(t1, t2):
      distance = math.sqrt(math.pow(t1.xcor()-t2.xcor(),2)+math.pow(t1.ycor()-t2.ycor(),2))
      if distance &lt; 30:
          return True
      else:
          return False
  
  def ball_move():
      while True:
          global ballspeedy
          global ballspeedx
          x = ball.xcor() + ballspeedx
          y = ball.ycor() + ballspeedy
          if y &gt; 285 or y &lt; -285:
              ballspeedy *= -1
  
          if x &lt; -295 or x &gt; 295:
              x = 0
              y = 0
  
          if isCollision(lbump, ball):
              ballspeedx *= -1
  
          if isCollision(rbump, ball):
              ballspeedx *= -1
          ball.setposition(x,y)
  </code></pre>