     (draw-sprite state 4 4 cell-size :flask)
     (draw-sprite state player-x player-y cell-size :player)
     (draw-text state game-x-cells 0 (str countdown " seconds"))))
+
+(defmethod render :finished
+  [state])
 
 (defn render-world
   [state]

                  :marginTop (px top)
                  :marginLeft (px left)})))

(defn ^:export main
  []
  (let [surface (surface-element)
        draw-context (.getContext surface "2d")
        timer (goog.Timer. 200)
        state (atom {:surface surface
                     :draw-context draw-context
                     :surface-width (.-width surface)
                     :surface-height (.-height surface)
                     :start-time (js/Date.)
                     :state :playing
                     :player [(pixels->cell (/ game-width 2))
                              (- (pixels->cell game-height) 1)]})]
    (set! (.-width surface) game-width)
    (set! (.-height surface) game-height)
    (events/listen timer goog.Timer/TICK (partial check-game state))
    (events/listen js/window event-type/RESIZE (partial resize state))
    (events/listen js/window event-type/KEYDOWN (partial keydown state))
    (.start timer)
    (resize state)
    (log-state @state)
    (render-world state)))

(main)

(def game-x-cells (pixels->cell game-width))
(def game-y-cells (pixels->cell game-height))

(def surface
  (let [surface (dom/getElement "surface")]
    (set! (.-width surface) game-width)
    (set! (.-height surface) game-height)
    surface))
(def draw-context (.getContext surface "2d"))

(def start-position
  [(pixels->cell (/ game-width 2))
   (- (pixels->cell game-height) 1)])

(defn initial-state
  []
  {:start-time (js/Date.)
   :state :playing
   :player start-position} )

(def keycode->key
  {kcs/SPACE :space
