> In the OOP languages, entity systems seem to be all the rage. I
> suggest stealing ideas from there if you can.


In this same vein, I'd recommend thinking about the following approach:

First, read up on reify and protocols. Next, create protocols for the
main areas of your engine. Perhaps start with IRender and
IPhysicalEntity

(defprotocol IRender
    (render [this]))

(defprotocol IPhysicalEntity
    (update-position [this timespan]))



then for the user ship, you can do something as simple as:

(defn new-ship [x y]
   (let [pos (atom {:x x :y y})]
        (reify
             IRender
                (render [this]
                    (render-ship-model pos))
             IPhysicalEntity
                (update-position [this timespan]
                    (swap! pos
                             #(hash-map :x (inc (:x %)) :y (:y %)))))))

there's bound to be errors in the above code, but you get the point.
The thing I love about the above example is that we've completely
abstracted away the parts of this engine. We can have entities that
implement different protocols, we can have a separate data structure
for each and every entity, depending on its needs, and everything is
abstracted nicely. Static objects can just implement IRender, and
invisible objects can implement IPhysicalEntity. Extend this to
implement ICollideable (for collision detection), and you have the
makings of a very extensible system.

Timothy

-- 
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