+1 for Daniels suggestion.
Swing can be quite bothersome if you just want a canvas and key-events.
I would avoid multimethods:
(defn calc-new-pos [xy prev-pos dir]
(condp = [xy dir]
[:x :right] (+ prev-pos step)
[:x :left]) (- prev-pos step)
[:y :down] (+ prev-pos step)
[:y
Or quil, a processing wrapper, would be well suited to this application.
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be
Cool!
If you want to make the Swing stuff more idiomatic, you could take a look
at Seesaw https://github.com/daveray/seesaw.
On 2 August 2013 17:11, eliassona...@yahoo.com wrote:
Below is a little (stupid) snake game I wrote using core.async and swing.
It uses channels for timer, keyboard
Below is a little (stupid) snake game I wrote using core.async and swing.
It uses channels for timer, keyboard input and repaint to make everything
nice and sequential.
Thought it could be a nice example of the power of core.async.
I'm not an experienced clojure/lisp developer so I'd be happy if