-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

no need for "IRender" since everything has a java.awt.polygon. i just
draw it. in a sense, the polygon is my IRender and it's data is the
implementation.

i was thinking about using a simple type (:asteroid, :ship, :bullet)
for each entity and pick an "advance"-function (input = complete old
game state + one specific entity, output = new entity) depending on it.
- ->
{:asteroid advance-asteroid :ship advance-ship}

i'd like to avoid mutable states as much as possible which means there
will be one atom or agent for the whole world and a bufferedimage.
other than that, i'd like to stay purely functional.

Am 31.10.2011 19:03, schrieb Timothy Baldridge:
>> 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
> 


- -- 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOruwPAAoJENRtux+h35aG0NsP/3CmDZHPnWjIYS2wULzTE4cp
t9w+Citz3ZEfK5KmLDpy2dPB9l5bu2K4r7cwcgfmLLdZ90rcxgcan+WbtkffiPwd
RZdB/E6IJrVPd2RvTt858VjNYvIeWxeU4XhpgS9EUBjiqRurQHrVrV/5bKFudRGn
E8WO+wYv8kMGRxlB/3YjYxhxRtqy7Kevaf508J3Tq+U49TBnzpBYPvO8yX+HzRO2
RNDVOr4S1ANf4OPn0l7AETxnEcvsI5D359JwSMGQ5whSk60kveZXTsMiD6nCFsQ0
2CD57iGlhHisNF78gnT78x+Qi1aMmkzWl2adfeXrW/zqZLXghLHaWamEy9dETATY
TZxRlvYgqkp7Bwqh4+PHCB20uzRPTHex2bSw6SqY53XYiK8IWCG6iecwz0t/cuOt
BxWRn+uTOlgX8FPZqX954eMmu1/5QjNRje5+i8kS7naRuXeZQLxwgZt6uFHN8jTS
H4s2aso0eWyfimTQXgwQx1K+81LzbF+bDk2iI/6lk6sdbCoD1RkaIzp5qYJIxU4v
zmFInbt+tPQFHtl8taEoUavN/Vc8//evcBDQpfdZ32JhzmZUHqGeJXEHQuVFojSr
ursyF9oiCrWRlm4j63hWrYYdf6OUIzOYlzN2ehXGWt0Ek8TbV2J36XY8Jf6sPu3v
9LVXoiGlFmrjEtPKxog0
=8KV+
-----END PGP SIGNATURE-----

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