-
-
Save halogenandtoast/6f2f3ac2ed0ba57acfa6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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