Stumbled upon the (very) incomplete Games::Tetris and it scratched my itch to learn some more Moose and try out threading in Perl. It was all surprisingly very painless.

With the code below, either set your module path or get it on CPAN (when available) and run

perl -MGames::Tetris::Complete -e "play" [width height]

where optional arguments width and height are the board dimensions in pixels. They default to 12x20.

Here's the code:

(caveats) Testing is, er, manual only. I've only done Win32. Speed is slightly more difficult than the classic version because I'm impatient.

Replies are listed 'Best First'.
Re: Tetris on the console
by andreas1234567 (Vicar) on Feb 11, 2011 at 11:01 UTC
    Nice. I would recommend to add dependencies to the Makefile.PL:
    diff --git a/Makefile.PL b/Makefile.PL index d1c98b6..2efb32a 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -11,7 +11,15 @@ WriteMakefile( ? ( 'LICENSE' => 'perl' ) : () ), PL_FILES => {}, - PREREQ_PM => { 'Test::More' => 0, }, + PREREQ_PM => { + 'Moose' => 0, + 'Moose::Util::TypeConstraints' => 0, + 'Test::More' => 0, + 'Term::ReadKey' => 0, + 'Time::HiRes' => 0, + 'Term::Screen::Uni' => 0, + 'Thread::Semaphore' => 0, + }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Games-Tetris-Complete-*' }, );
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]