<commit_before>(ns cloj.core
  (:require 

    [cloj.math.misc :refer [cos-01]]
    [cloj.math.vec2 :refer [v2]]

    [cloj.protocols.system    :as sys-p]
    [cloj.protocols.window    :as win-p]
    [cloj.protocols.resources :as res-p]

    [cloj.protocols.render    :as rend-p :refer [clear!
                                                 box!]]
    [cloj.protocols.keyboard  :as key-p]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn funny-col [t]
  [(cos-01 t)
   (cos-01 (* t 3.1))
   (cos-01 (* t (cos-01 (* t 2))))
   1.0 ])

(defn draw-frame [r t]
  (do
    (clear! r (funny-col t))
    (box! r (v2 10 10) (v2 100 100) [0 0 0 1])))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defprotocol IGameKeys
  (update! [_])
  (quit? [_])
  (up? [_])
  (down? [_])
  (left? [_])
  (right? [_])
  (fire? [_]))

(defn any-keys-pressed? [keypfn ks]
  (->
    (fn [r v]
      (or r (keypfn v)))
    (reduce false ks)))

(defn mk-game-keys [keyb key-defs]
  (let [any-pressed? (fn [kk]
                       (any-keys-pressed?
                         (:state #(key-p/get-key-state keyb %))
                         (kk key-defs)))]

    (reify
      IGameKeys
      (update![_] (key-p/update! keyb))
      (quit?  [_] (any-pressed? :quit))
      (up?    [_] (any-pressed? :up))
      (down?  [_] (any-pressed? :down))
      (left?  [_] (any-pressed? :left))
      (right? [_] (any-pressed? :right))
      (fire?  [_] (any-pressed? :fire))
      ))<commit_msg>Minor<commit_after>(ns cloj.core
  (:require 

    [cloj.math.misc :refer [cos-01]]
    [cloj.math.vec2 :refer [v2]]

    [cloj.protocols.system    :as sys-p]
    [cloj.protocols.window    :as win-p]
    [cloj.protocols.resources :as res-p]

    [cloj.protocols.render    :as rend-p :refer [clear!
                                                 box!]]
    [cloj.protocols.keyboard  :as key-p]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn funny-col [t]
  [(cos-01 t)
   (cos-01 (* t 3.1))
   (cos-01 (* t (cos-01 (* t 2))))
   1.0 ])

(defn draw-frame [r t]
  (do
    (clear! r (funny-col t))
    (box! r (v2 10 10) (v2 100 100) [0 0 0 1])))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defprotocol IGameKeys
  (update! [_])
  (quit?   [_])
  (up?     [_])
  (down?   [_])
  (left?   [_])
  (right?  [_])
  (fire?   [_]))

(defn any-keys-pressed? [keypfn ks]
  (->
    (fn [r v]
      (or r (keypfn v)))
    (reduce false ks)))

(defn mk-game-keys [keyb key-defs]
  (let [any-pressed? (fn [kk]
                       (any-keys-pressed?
                         (:state #(key-p/get-key-state keyb %))
                         (kk key-defs)))]

    (reify
      IGameKeys
      (update![_] (key-p/update! keyb))
      (quit?  [_] (any-pressed? :quit))
      (up?    [_] (any-pressed? :up))
      (down?  [_] (any-pressed? :down))
      (left?  [_] (any-pressed? :left))
      (right? [_] (any-pressed? :right))
      (fire?  [_] (any-pressed? :fire))
      ))
{'fraction_non_alphanumeric': 0.28339291517712056, 'fraction_numerical': 0.021449463763405913, 'mean_word_length': 2.1280487804878048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2243849', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1199, 'n_words': 244}