> http://www.flickr.com/photos/nakkaya/4200386988/in/set-72157623036408444/
>
> I would very much like to hear your feedback on the code.

I watched the movie -- very cool stuff! Great way to spend a weekend :)

I only skimmed your code. It looks pretty decent, though there are  
opportunities for simplification. E.g.,

   (if (= p :1) (:x (:1 @player)) (:x (:2 @player)))

if p is always either :1 or :2, this can be turned into

   (:x (p @player))

Similarly, in something like move-ball:

   (cond (= 1  (:x (:dir @ball))) (+ (:x @ball) (:right step))
         (= -1 (:x (:dir @ball))) (+ (:x @ball) (:left step))
         :else (:x @ball))

I'd define

   (defn direction [d]
     (cond (= d 1)  :right
           (= d -1) :left
           :else    (constantly 0)))

-- the only reason you can't use a map is that boxed Java numerics  
don't hash
the same -- and alter move-ball to use

   (+ (:x @ball)
      ((direction (:x (:dir @ball))) step)

There are a few other changes you can make by altering  
representations... for
example, you use :1 and :2 for the players, but you could also use 0  
and 1 and
directly index an array.


-- 
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 patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to