     (assoc state :ball (assoc ball :vx (* -1 (:vx ball))))
     state))
 
+(defn score-phase!
+  [{:keys [ball score-1 score-2] :as state}]
+  (if (<= 0 (:x ball) SCALE-W)
+    state
+    (let [{:keys [x vx radius]} ball
+          {score1 :score} score-1
+          {score2 :score} score-2
+          p1? (> x SCALE-W)
+          p2? (< x 0)
+          s1 (assoc score-1 :score (if p1? (inc score1) score1))
+          s2 (assoc score-2 :score (if p2? (inc score2) score2))
+          ball (cond
+                 p2? (assoc ball :x (- SCALE-W 25) :y (/ SCALE-H 2))
+                 p1? (assoc ball :x 25 :y (/ SCALE-H 2))
+                 :else ball)]
+      (assoc state :score-1 s1 :score-2 s2 :ball ball))))
+
 (defn animate-loop!
   [state ctx]
-  (swap! state #(-> % move-phase! collision-phase!))
+  ;; if start-mode:
+  ;; ...
+  ;; if play-mode:
+  (swap! state #(-> % move-phase! collision-phase! score-phase!))
+  ;; if win-mode:
+  ;; ...
   (draw-phase! state ctx)
   (.requestAnimationFrame js/window (partial animate-loop! state ctx)))
 

(def SCALE-W 800)
(def SCALE-H 450)

(def KEYBOARD
  {40 :down
   38 :up


(extend-type Ball
  IMovable
  (move [{:keys [x y vx vy radius oob?] :as ball}]
    (when-not oob?
      (cond
        (= x radius)
        (assoc ball :oob? false :x -100)
        ;;
        (= x (- SCALE-W radius))
        (assoc ball :oob? false :x (+ SCALE-W 100))
        ;;
        :else
        (let [vy (if (< radius y (- SCALE-H radius)) vy (* -1 vy))]
          (assoc ball :x (+ x vx) :y (+ y vy) :vy vy))))))

;;-----------------------------------------------------------------------------
;; Controllable Objects
