Skip to content

Instantly share code, notes, and snippets.

@verma verma/working-but-ugly.clj Secret
Last active Aug 29, 2015

Embed
What would you like to do?
(def level ["^------$"
"< >"])
(def symbols
{ \^ '(0 0 64 64)
\- '(64 0 64 64)
\< '(0 64 64 64)
\> '(128 64 64 64)
\ '(64 64 64 64)
\$ '(128 0 64 64) })
(defn game [state ctx]
(doseq [[line row] (map list level (iterate inc 0))]
(doseq [[c i] (map list line (iterate inc 0))]
(let [[sx sy sw sh] (get symbols c)]
(blit! ctx image sx sy sw sh (* 64 i) (* 64 row))))))
@alandipert

This comment has been minimized.

Copy link

commented Jul 1, 2014

An alternative:

(def transpose (partial map vector))

(defn game [state ctx]
  (doseq [[line row] (transpose level (range))
          [c i]      (transpose line (range))
          :let       [[sx sy sw sh] (symbols c)]
          (blit! ctx image sx sy sw sh (* 64 i) (* 64 row))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.