Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Forked from newsomc/atom.cljs
Last active December 14, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcromartie/5142741 to your computer and use it in GitHub Desktop.
Save jcromartie/5142741 to your computer and use it in GitHub Desktop.
(defn make-ghost
[color]
{:get-tick 0, :eatable nil, :color nil, :eaten nil, :specs color, :position nil, :due nil, :map nil, :direction nil})
(def ghost-specs ["#00FFDE" "#FF0000" "#FFB8DE" "#FFB847"])
(def game-state (atom {:state nil
:audio []
:ghosts (mapv make-ghost ghost-specs)
:eaten-count 0
:level 0
:tick 0
:n-score 0
:block-size nil}))
(def ghost-init-state
{:eaten true, :eatable true, :position {:x 90, :y 80}})
(defn reset-ghost
[ghost]
(merge-with merge ghost ghost-init-state))
(defn reset-ghost-state! [ghost]
(swap! game-state (fn [state] (update-in [:ghosts] #(map reset-ghost %)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment