[reactive] First draft of reactive-tetris

Peter Verswyvelen bugfact at gmail.com
Mon Nov 17 19:03:07 EST 2008

I forgot to mention that if you want to run the code I've attached, you
should compile it with -O or -O2. The interpreter is too slow to handle the
brute force approach I applied...

On Tue, Nov 18, 2008 at 12:55 AM, Peter Verswyvelen <bugfact at gmail.com>wrote:

> Excellent!
> I'm still new at Haskell, and learning Reactive, but attached is some
> code I would like to convert to Reactive, one day. I'm sure your Tetris
> example can help me do so, thanks!
> My code is most likely horrible; I did not clean it up, added no comments,
> and it contains various hacks and stuff that could be done a zillion times
> better and shorter by someone that actually knows Haskell well. But the
> result is amusing to look at, it could be a silly screen saver.
> The code is a simple semi-physical simulation of a bunch of bouncing balls.
> The point of intersection is computed exactly, so the balls can move as fast
> as possible. Moving the mouse to the right makes the balls move faster. It
> would be interesting to see if Reactive can handle this: the sampling time
> step needs to be rewound to the time of the first collision (or it could be
> handled differently in a Reactive setting, I don't know)
> Currently the code needs Yampa and GLFW (from Hackage), but I use Yampa
> only for its vector space and forceable classes...
> If anyone else wants to give this a shot: the more tutorials and demos that
> use Reactive, the better :)
> Cheers,
> Peter Verswyvelen
> 2008/11/17 Creighton Hogg <wchogg at gmail.com>
>> Hey Reactive,
>> Since I have no hosting space I'm actually going to include the
>> implementation as an attachment all in one file.  It's not very long anyway,
>> so it should be alright.
>> A few caveats:
>> This code is still _really_ ugly, but it does work as far as I've tested
>> There is no game over, you need to quit manually
>> There is no score or level adjustment yet.  I need to add that when I have
>> more time, i.e. after this week
>> That being said, my first real reactive program was surprisingly simple
>> once I got comfortable with the semantics.  The actual reactive code isn't
>> that complicated, but it did take a pretty big shift in thinking from
>> writing explicit game loops.
>> I've included a good bit of comments so it hopefully it isn't too hard to
>> follow, but if there are any questions about why I did something a
>> particular way (the answer may be 'I'm dumb') please e-mail me or find me on
>> #haskell.
>> _______________________________________________
>> Reactive mailing list
>> Reactive at haskell.org
>> http://www.haskell.org/mailman/listinfo/reactive
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/reactive/attachments/20081118/6f9489ed/attachment.htm

More information about the Reactive mailing list