Skip to content

Instantly share code, notes, and snippets.

@halogenandtoast
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halogenandtoast/6f2f3ac2ed0ba57acfa6 to your computer and use it in GitHub Desktop.
Save halogenandtoast/6f2f3ac2ed0ba57acfa6 to your computer and use it in GitHub Desktop.
; Uncaught Error: Assert failed: No more than 1024 pending takes are allowed on a single channel.
; (< (.-length takes) impl/MAX-QUEUE-SIZE)
(def keys-pressed (chan))
(defn update-player [player]
(go (while true
(let [key-pressed (<! keys-pressed)]
(case key-pressed
37 (update-in player [:paddle] move-paddle -4 0)
39 (update-in player [:paddle] move-paddle 4 0)
player)))))
(defn init []
(events/listen js/window "keydown" (fn [e] put! keys-pressed (read-string (.-keyCode e)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment