On Sun, Aug 30, 2009 at 6:01 AM, Elliott Slaughter < elliottslaugh...@gmail.com> wrote:
> > All game simulation models I've seen used graphs of mutable objects; > I'm not entirely sure how to move to a more functional model. One the > one hand, reallocating the game world on every frame seems excessive > (even if Java's GC is fast), and on the other hand putting refs > everywhere a value could potentially change seems equally excessive > (and probably detrimental to performance). I'm curious as well to see which approaches work best. One common mistake when coming to Clojure is thinking that you need to wrap every individual mutable value. For example if you have a hundred game sprites you could (and probably should) store them as maps in a single vector wrapped by a ref or atom. Then map over the sprite positions dispatching to the correct updater function based on their type metadata. Depending on how performance oriented your game design is, you may need to resort to using Java objects for critical bits and using Clojure more as a functional "scripting" layer. David --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---