Not sure, but maybe you can define a Drawable  class with a method in converting inner state to something draw func could use, so it would be like this:<span></span><div><br></div><div>draw :: Drawable a =&gt; a -&gt; IO ()<br>
<br>вторник, 27 ноября 2012 г. пользователь Nathan Hüsken  писал:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey,<br>
<br>
When writing games in other (imperative) languages, I like to separate<br>
the game logic from the rendering. For this I use something similar to<br>
the observer pattern.<br>
<br>
With rendering I mean anything only related to how objects are drawn to<br>
the screen. Animation state for example.<br>
<br>
On my journey of exploring game programming with haskell (and FRP), I<br>
wonder what a good way of archiving something similar would be.<br>
<br>
If the rendering has no internal state, one can just write a function<br>
<br>
draw :: GameLogicState -&gt; IO ()<br>
<br>
But when the rendering of an object has an internal state (e.g.<br>
animation frame) than this is not possible.<br>
<br>
Now I could write a Wire/Signal (whatever FRP implementation I use) that<br>
translates to a RenderingState:<br>
<br>
render :: Signal GameLogicState RenderingState<br>
draw :: RenderingState -&gt; IO ()<br>
<br>
which is fine, except when my game is made of many objects.<br>
Than I need to associate the state of one object in GameLogicState with<br>
a sub-signal in render.<br>
That could be done by giving every object an ID and letting<br>
GameLogicState contain a map from IDs to ObjectLogicState.<br>
<br>
I fear that when I really have a lot of objects, assembling and<br>
decomposing the map could become a major bottleneck.<br>
<br>
So I am wondering: Is there (or can someone think of) a different<br>
pattern by which this could be archived? Or asked different: How would<br>
you do it?<br>
<br>
Thanks!<br>
Nathan<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;Haskell-Cafe@haskell.org&#39;)">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br>-- <br>Best<div>Timur DeTeam Amirov</div><div>Moscow, Russia</div><br>