Thank you for the insights.

What I will do is make a separate protocol for drawing and acting.
There might indeed be objects that only act but not draw, and other
objects that do not act but just draw themselves, not necessarily
using a sprite.

Collision could be another protocol like (defprotocol solid (rectangle
[this])), as not all objects are actually supposed to collide.

In this way, a basic object could be defined as

(defrecord [x y w h sprite]
  actor
  (act [this _] (update-in this [:x] inc))
  visible
  (draw [this canvas] (.drawImage canvas x y sprite canvas))
  solid
  (rectangle (Rectangle. x y w h)))

This looks good, thanks!

Pepijn

On Apr 4, 10:49 pm, Timothy Baldridge <tbaldri...@gmail.com> wrote:
> In a test game engine I developed, I simply used maps and created a
> sort of "duck" typing. It actually worked quite well. For instance,
> each entity would have a :physics-update function:
>
> ((:physics-update entity) entity timespan)
>
> It ended up working very well. I had a few thousand entities, all
> using agents to update. The graphics front-end would then just deref
> each entity and then do:
>
> ((:draw-func entity) entity))
>
> To draw it.
>
> 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