samples/04_physics_and_collisions/08_bouncing_on_collision/app/peg.rb
def collisionWithBounce? args
    squareDistance = (  # the squared distance between the ball's center and this peg's center
      (args.state.ball.center.x - @center.x) ** 2.0 +
      (args.state.ball.center.y - @center.y) ** 2.0
    )
    radiusSum = (  # the sum of the radius squared of the this peg and the ball
      (args.state.ball.radius + @radius) ** 2.0
    )
    # if the squareDistance is less or equal to radiusSum, then there is a radial intersection between the ball and this peg
    return (squareDistance <= radiusSum)
  end
# do two circles (the ball and this peg) intersect
do two circles (the ball and this peg) intersect
do two circles ( the ball and this peg ) intersect
def collisionWithBounce? args
    squareDistance = (  
      (args.state.ball.center.x - @center.x) ** 2.0 +
      (args.state.ball.center.y - @center.y) ** 2.0
    )
    radiusSum = (  
      (args.state.ball.radius + @radius) ** 2.0
    )
    return (squareDistance <= radiusSum)
  end
def collisionWithBounce? args squareDistance = ( ( args . state . ball . center . x - @center . x ) ** 2.0 + ( args . state . ball . center . y - @center . y ) ** 2.0 ) radiusSum = ( ( args . state . ball . radius + @radius ) ** 2.0 ) return ( squareDistance <= radiusSum ) end
do two circles (the ball and this peg) intersect
do two circles ( the ball and this peg ) intersect
# the squared distance between the ball's center and this peg's center # the sum of the radius squared of the this peg and the ball # if the squareDistance is less or equal to radiusSum, then there is a radial intersection between the ball and this peg
args