12. Concurrency
Activity 12.01: A DOM Whack-a-mole Game
Solution:
- Create a project with
lein figwheel
:lein new figwheel packt-clj.dom-whackamole -- --rum
- Move to the new
packt-clj.dom-whackamole
directory and start a ClojureScript REPL:lein figwheel
In your browser, at
localhost:3449/index.html
, you should see the default Figwheel page: - Open
dom-whackamole/src/packt-clj/dom-whackamole/core.cljs
in your editor or IDE. This is where you will write all the remaining code. - Define the atoms that will determine the game's state:
(def game-length-in-seconds 20) (def millis-remaining (atom (* game-length-in-seconds 1000))) (def points (atom 0)) (def game-state (atom :waiting)) (def clock-interval (atom nil)) (def moles (atom (into []             (repeat 5 {:status :waiting                  ...