use SDL::Tutorial::Tetris::Model::Pieces; my ($piece, $rotation) = SDL::Tutorial::Tetris::Model::Pieces->random(); my ($init_x, $init_y) = SDL::Tutorial::Tetris::Model::Pieces->init_xy($piece,$rotation); for my $y (0..4) { for my $x (0..4) { print SDL::Tutorial::Tetris::Model::Pieces->block_color($piece,$rotation,$x,$y); } print "\n"; }
This modules holds the game data, and the means to interact to it.
Basically, we have a set of named pieces (SQUARE, LINE, T_SHAPE; L_SHAPE, N_SHAPE; L_SHAPE_MIRROR, N_SHAPE_MIRROR).
Returns a random piece and rotation.
Returns the initial (x,y) coordinates for each block and rotation.
Given a block, rotation, and (x,y) coordinates, it returns the color of the block in that point.
To install SDL::Tutorial::Tetris, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL::Tutorial::Tetris
CPAN shell
perl -MCPAN -e shell install SDL::Tutorial::Tetris
For more information on module installation, please visit the detailed CPAN module installation guide.