NAME

Games::Tetris - representation of a tetris game state

SYNOPSIS

use Games::Tetris;
my $well = Games::Tetris->new;
my $ess = $well->new_shape(' +',
                           '++',
                           '+ ');
$well->drop( $ess, 3, 1 );
$well->print;

DESCRIPTION

This module can be used as the rules engine for the game of tetris. It allows you to create a well and drop pieces in it. The well tracks the status its contents and handles completed line removal.

METHODS

new

Creates a new gamestate

Takes the following optional parameters:

well an initial well, an array of arrays. use undef to indicate an empty cell, any other value is considered occupied

or

width, depth dimensions of a new well (defaults to 15 x 20)

new_shape

delegates to Games::Tetris::Shape->new

print

used by the testsuite. prrints the current state of the well

->fits( $shape, $x, $y )

returns a true value if the given shape would fit in the well at the location $x, $y

->drop( $shape, $x, $y )

returns false if the shape will not fit at the location indicated by $x, $y

if the shape can be dropped it will be advanced to the bottom of the well and the return value will be the rows removed by the dropping operation, if any, as an array reference

TODO

$shape->rotate
Tk/Qt/Wx interface
Network Code
Watch all tuits go bye bye

AUTHOR

Richard Clamp <richardc@unixbeard.net>

COPYRIGHT

Copyright (C) 2003 Richard Clamp. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Games::Tetris::Shape