anchor.diff:  (defparameter +max-dx+ (* 1/2 +canvas-width+))
   (defparameter +max-dy+ (* 1/2 +canvas-height+))
   
  -(defparameter +min-radius+ 8)
  -(defparameter +max-radius+ 25)
  +(defparameter +min-radius+ 10)
  +(defparameter +max-radius+ 15)
   
   (defparameter +g-constant+ -1000)
   
  
positive.code:     (when (or (> (+ y radius) +canvas-height+)
                (< (- y radius) 0))
        (setf dy (- dy)))
      (incf x dx)
      (incf y dy)))
  
  (defmethod draw (cr (ball ball))
    (with-slots (x y color radius) ball
  
negative.code:     (cairo-set-source-color cr black)
      (cairo-circle cr x y radius)
      (cairo-stroke cr)))
  
  (defun random-color ()
    (let ((base (list (random 1.0) (random 1.0) (random 1.0))))
      (mapcar (lambda (x) (/ x (apply #'max base))) base)))
  
  (defmethod collision ((ball-1 ball) (ball-2 ball))
    ;;; see http://en.wikipedia.org/wiki/Elastic_collision the new-dx and new-dy
    ;;; functions are taken directly from the physics equations presented there
    (labels ((movement-angle (ball)
               (with-slots (dx dy) ball
                 (atan dy dx)))
             (contact-angle (ball other)
               (atan (- (y other) (y ball)) (- (x other) (x ball))))
             (new-dy (ball other)
               (let ((phi (contact-angle ball other))
                     (theta-1 (movement-angle ball))
                     (theta-2 (movement-angle other))
                     (v1 (velocity ball))
                     (m1 (mass ball))
                     (v2 (velocity other))
                     (m2 (mass other)))
                 (+ (* (/ (+ (* v1 (cos (- theta-1 phi)) (- m1 m2)) (* 2 m2 v2 (cos (- theta-2 phi)))) (+ m1 m2)) (sin phi)) (* v1 (sin (- theta-1 phi)) (sin (+ phi (/ pi 2)))))))
             (new-dx (ball other)
               (let ((phi (contact-angle ball other))
                     (theta-1 (movement-angle ball))
                     (theta-2 (movement-angle other))
                     (v1 (velocity ball))
                     (m1 (mass ball))
                     (v2 (velocity other))
                     (m2 (mass other)))
                 (+ (* (/ (+ (* v1 (cos (- theta-1 phi)) (- m1 m2)) (* 2 m2 v2 (cos (- theta-2 phi)))) (+ m1 m2)) (cos phi)) (* v1 (sin (- theta-1 phi)) (cos (+ phi (/ pi 2))))))))
      (let ((new-dx-1 (new-dx ball-1 ball-2))
            (new-dx-2 (new-dx ball-2 ball-1))
            (new-dy-1 (new-dy ball-1 ball-2))
            (new-dy-2 (new-dy ball-2 ball-1)))
        (with-slots (dx dy) ball-1
          (setf dx new-dx-1)
          (setf dy new-dy-1))
        (with-slots (dx dy) ball-2
          (setf dx new-dx-2)
          (setf dy new-dy-2)))
      (loop
         do (progn (update ball-1) (update ball-2))
         while (overlapp ball-1 ball-2))))
  
  (defun distance (one two)
    (sqrt (+ (expt (- (x one) (x two)) 2)
             (expt (- (y one) (y two)) 2))))
  
  (defmethod overlapp ((ball-1 ball) (ball-2 ball))
    (when (< (distance ball-1 ball-2)
             (+ (radius ball-1) (radius ball-2)))
      t))
  
  (defun do-collisions (balls)
    (labels ((check-ball-against (ball others)
               (when others
                 (when (overlapp ball (car others)) (collision ball (car others)))
                 (check-ball-against ball (cdr others)))))
      (when balls
        (check-ball-against (car balls) (cdr balls))
        (do-collisions (cdr balls)))))
  
  (defun main ()
    (within-main-loop
      (let ((runningp nil)
            (balls (loop repeat +num-balls+ collect (random-ball)))
            (window (make-instance 'gtk-window
                                   :type :toplevel
  