 (defmethod move :ship [{:keys [direction rotation-speed position speed acceleration shots] :as ship}]
   (let [direction (+ direction (* rotation-speed turn-millis 0.001))
         speed (vec+vec speed (rotate-vec direction [0 (* acceleration turn-millis 0.001)]))
-        position (vec+vec speed position)
+        [x y] (vec+vec speed position)
+        position [(mod x width) (mod y height)]
         shots (->> shots
                    (filter #(not (out-of-bounds? %)))
                    (map move))]

; game
; ----------------------------------------------------------

(defn game-panel [frame ship asteroid]
  (proxy [JPanel ActionListener KeyListener] []
    (paintComponent [g]                                     ; <label id="code.game-panel.paintComponent"/>
      (proxy-super paintComponent g)
      (paint g @ship)
      (paint g @asteroid))
    (actionPerformed [e]                                    ; <label id="code.game-panel.actionPerformed"/>
      (update-positions! ship asteroid)
      (when (lose? @ship)
        (reset-game! ship asteroid)
        (JOptionPane/showMessageDialog frame "You lose!"))
      (when (win? @ship)
        (reset-game! ship asteroid)
        (JOptionPane/showMessageDialog frame "You win!"))
      (.repaint this))
    (keyPressed [e]


; END: constants

(defn random [from to]
  (let [range (- to from)]
    (+ from (rand range))))

(defn vary [variance n]
  (let [from (* n (- 1 variance))
        to (* n (+ 1 variance))]
    (random from to)))

; transformation math:

(defn invert [mat]
