Good to know ;)
fwsuperhero
10
Posts
A member registered May 28, 2023 · View creator page →
Creator of
Recent community posts
Hi, it is related to my previous comment:
your post in aMAZE jam comments
There is a solution. You save pressed keys into the state and then you reduce on top of them.
You can see the implementation in this framework based on top of Quill.
https://github.com/Kimbsy/quip/blob/master/src/quip/input.clj
(defn key-pressed "Reduce applying a handler function: (f state e) accross the collection of `:key-pressed-fns` in the current scene." [{:keys [input-enabled? scenes current-scene] :as state} e] (if input-enabled? (let [default-handled-state (default-key-pressed state e) scene-handlers (get-in scenes [current-scene :key-pressed-fns])] (reduce (fn [acc-state f] (f acc-state e)) default-handled-state scene-handlers)) state)) (defn key-released "Reduce applying a handler function: (f state e) accross the collection of `:key-released-fns` in the current scene." [{:keys [input-enabled? scenes current-scene] :as state} e] (if input-enabled? (let [default-handled-state (default-key-released state e) scene-handlers (get-in scenes [current-scene :key-released-fns])] (reduce (fn [acc-state f] (f acc-state e)) default-handled-state scene-handlers)) state))
When i release an arrow the character is still moving sometimes.
More info here: 1 second ago