[plt-scheme] Re: tetris

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Wed Feb 27 22:24:58 EST 2008

David Van Horn wrote:
> Jon Rafkind wrote:
>> I thought the recently uploaded tetris game to planet was fun so I
>> converted it to use the Allegro package instead of htdp. Theres not
>> really much of a point and its not like it runs better or anything, but
>> it was good to compare htdp's functional style with Allegro's mostly
>> imperative style. It probably won't work too well in osx.
>> Tetris on planet:
>> http://planet.plt-scheme.org/display.ss?package=tetris.plt;owner=dvanhorn
>> Code attached if you want to try it.
> Hi Jon,
> Thanks for the code and interest in the Tetris package.  I'd be happy
> to include an Allegro version of the game in the package (I also have
> a 3D OpenGL version that will make it in eventually), but with the
> code you sent, I noticed a couple things:
>   - when the game ends, DrScheme hangs, requiring me to manually kill
>     DrScheme after each play.
I think someone sent me a bug report about Allegro on osx along the
lines of this a while ago but I haven't fixed it yet.
>   - once I move left, I always move left, regardless of keyboard input.
I hacked keyinput into tetris but it could be done better. This is one
of the things that doesn't work too well in osx, though. The input
thread in osx is manually activated from the scheme thread( during the
call to easy-init ) whereas on other platforms the input thread is a
native pthread running in the background. Suffice to say the scheme
thread usually isn't as fast to update as other platforms so keys
sometimes get stuck. Actually now that I think about, adding a (sleep)
somewhere in (game-loop) might fix the problem. I'll test it out when I
get a chance.

Posted on the users mailing list.