<commit_before>(ns try-lwjgl.logic
  (:import [org.lwjgl.input Mouse Keyboard])
  (:require [try-lwjgl.input :as input]))

(def angle (atom 0.1))
(def angle-speed (atom 0.5))
(def mode (atom :angle-speed))

(defn inc-angle []
  (swap! angle #(+ % @angle-speed)))

(defn key-left-down []
  (println "Key LEFT down"))

(def up-down-callbacks
  {:angle-speed {:atom angle-speed, :amount 0.1}})

(defn adjust-value [type up?]
  (let [spec (type up-down-callbacks)
        value-atom (:atom spec)
        amount (:amount spec)]
    (swap! value-atom #(identity (if up? (+ % amount) (- % amount))))
    (println "New value:" @value-atom)
    @value-atom))

(defn key-up []
  (adjust-value @mode true))

(defn key-down []
  (adjust-value @mode false))

(defn set-mode [m]
  (println "Mode:" m)
  (swap! mode (fn [_] identity m)))

(def player-position (atom [0.0, 1.0, 10.0]))

(defn move-sideways [direction]
  (let [index 0]
    (swap! player-position (fn [pos]
                             (let [old-val (pos index)
                                   new-val (+ old-val (* direction 1.0))]
                               (assoc pos index new-val))))))

(defn move-forward [direction])

(def listeners
  [{:key :left, :down? true, :repeat? false :callback key-left-down}

   ;; Navigation
   {:key :a, :down? true, :repeat? false :callback (fn [] (move-sideways -1.0))}
   {:key :d, :down? true, :repeat? false :callback (fn [] (move-sideways 1.0))}
   {:key :w, :down? true, :repeat? false :callback (fn [] (move-forward 1.0))}
   {:key :s, :down? true, :repeat? false :callback (fn [] (move-forward -1.0))}

   ;; Debugging keys
   {:key :up, :down? true, :repeat? false :callback key-up}
   {:key :down, :down? true, :repeat? false :callback key-down}
   {:key :1, :down? true, :repeat? false :callback (fn [] (set-mode :angle-speed))}
   {:key :2, :down? true, :repeat? false :callback (fn [] (set-mode :eye-z))}])

(defn register-listeners []
  (doseq [listener listeners]
    (input/register-key-callback listener)))

(defn init []
  (input/init)
  (register-listeners))

(defn update [delta]<commit_msg>Forward/backward movement<commit_after>(ns try-lwjgl.logic
  (:import [org.lwjgl.input Mouse Keyboard])
  (:require [try-lwjgl.input :as input]))

(def angle (atom 0.1))
(def angle-speed (atom 0.5))
(def mode (atom :angle-speed))

(defn inc-angle []
  (swap! angle #(+ % @angle-speed)))

(defn key-left-down []
  (println "Key LEFT down"))

(def up-down-callbacks
  {:angle-speed {:atom angle-speed, :amount 0.1}})

(defn adjust-value [type up?]
  (let [spec (type up-down-callbacks)
        value-atom (:atom spec)
        amount (:amount spec)]
    (swap! value-atom #(identity (if up? (+ % amount) (- % amount))))
    (println "New value:" @value-atom)
    @value-atom))

(defn key-up []
  (adjust-value @mode true))

(defn key-down []
  (adjust-value @mode false))

(defn set-mode [m]
  (println "Mode:" m)
  (swap! mode (fn [_] identity m)))

(def player-position (atom [0.0, 1.0, 10.0]))

(defn move [axis amount]
  (swap! player-position (fn [pos]
                           (let [old-val (pos axis)
                                 new-val (+ old-val (* amount 1.0))]
                             (assoc pos axis new-val)))))

(defn move-sideways [amount]
  (move 0 amount))

(defn move-forward [amount]
  (move 2 (* -1.0 amount)))

(def listeners
  [{:key :left, :down? true, :repeat? false :callback key-left-down}

   ;; Navigation
   {:key :a, :down? true, :repeat? false :callback (fn [] (move-sideways -1.0))}
   {:key :d, :down? true, :repeat? false :callback (fn [] (move-sideways 1.0))}
   {:key :w, :down? true, :repeat? false :callback (fn [] (move-forward 1.0))}
   {:key :s, :down? true, :repeat? false :callback (fn [] (move-forward -1.0))}

   ;; Debugging keys
   {:key :up, :down? true, :repeat? false :callback key-up}
   {:key :down, :down? true, :repeat? false :callback key-down}
   {:key :1, :down? true, :repeat? false :callback (fn [] (set-mode :angle-speed))}
   {:key :2, :down? true, :repeat? false :callback (fn [] (set-mode :eye-z))}])

(defn register-listeners []
  (doseq [listener listeners]
    (input/register-key-callback listener)))

(defn init []
  (input/init)
  (register-listeners))

(defn update [delta]
{'fraction_non_alphanumeric': 0.19262391355414613, 'fraction_numerical': 0.012919896640826873, 'mean_word_length': 3.066857688634193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5075098', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1554, 'n_words': 450}