[Haskell-beginners] netwire and "dynamic" list of objects
es at ertes.de
Tue Apr 10 13:57:02 CEST 2012
Nathan Hüsken <nathan.huesken at posteo.de> wrote:
> I have a simple SDL based graphic demo, which I am trying (for
> educational purposes) to rewrite utilizing netwire.
> The demo basically consists of a State which contains a list of object
> But I avoided rewriting "updateState" in wire format. But I have no
> Idea how to do that.
> How do I handle a dynamic list of objects in a wire?
Well, you are not really using FRP here. You are just forcing this
application into the FRP model. Your only behavior is the application
itself. This works, but buys you nothing.
The first step to actually making use of FRP here is to get rid of the
concept of "updating" something. Express your game objects themselves
player :: GameWire (Input, [Wall]) Player
wall :: GameWire a Wall
enemy :: GameWire (Player, [Wall]) Enemy
This allows you to write static game worlds. After that you can move to
dynamic game worlds using wire transformers from
Control.Wire.Trans.Combine. It is also pretty straightforward to write
your own wire transformers for this purpose. You probably want to do
that later -- just look at the source code.
nightmare = unsafePerformIO (getWrongWife >>= sex)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners