                 c (vec- (:pos (nodes (:node-c h))) (:pos (nodes (:node-b h))))]
                 (angle a c))
             :modifier-angle 0.0
-            :strength 1000000))
+            :strength 2000000))
         hinges)
 })
 

                (update-node-velocities
                    (:nodes state)
                    (calculate-all-node-forces state)
                    tick-step)
                tick-step)))

(defn tick [game-state-ref input-state] (do
    (swap! game-state-ref #(tick-imp % tick-step input-state))))

(defn world-to-screen [[x y]]
    [x (- 275 y)])


(defn calculate-ground-forces [nodes]
    (zipmap (keys nodes)
        (map (fn [{[ _ y ] :pos}]
            (if (< y 0)
                (vec* [0 (- y)] ground-rebound-strength)
                [0 0]))
            (vals nodes))))

(defn calculate-ground-impulses [nodes time-step]
    (let [loss (- 1.0 (Math/exp (- (* time-step ground-drag-factor))))]
        (zipmap (keys nodes)
            (map (fn [{[ _ y ] :pos [ xv yv ] :vel mass :mass}]
                (if (< y 0)
                    (vec* [(- xv) (Math/max 0 (- yv))] (* loss mass))
                    [0 0]))
                (vals nodes)))))

(defn calculate-air-impulses [nodes time-step]
    (let [loss (- 1.0 (Math/exp (- (* time-step air-drag-factor))))]
        (zipmap (keys nodes)
            (map (fn [{[_ y] :pos vel :vel mass :mass}]
                (if (< y 0)
                    [0 0]
                    (vec* vel (* -1 loss mass))))
                (vals nodes)))))

(defn calculate-all-node-forces [{:keys [nodes springs hinges]}]
    (merge-with vec+
        (calculate-spring-forces nodes springs)
        (calculate-hinge-forces nodes hinges)
        (calculate-gravity-forces nodes)
        (calculate-ground-forces nodes)))

(defn calculate-all-node-impulses [nodes time-step]
    (merge-with vec+
        (calculate-ground-impulses nodes time-step)
        (calculate-air-impulses nodes time-step)))

(defn update-node-velocities [nodes forces impulses time-step]
    (merge-with
        (fn [n i] (assoc n
            :vel (vec+
                (:vel n)
                (vec* i (/ 1.0 (:mass n))))))
        (merge-with
            (fn [n f] (assoc n
                :vel (vec+
                    (:vel n)
                    (vec* f (/ time-step (:mass n))))))
            nodes
            forces)
        impulses))

(defn update-node-positions [nodes time-step]
    (zipmap (keys nodes) (map (fn [n]
