Kartik Thakore > SDL-Tutorial-Tetris-0.04 > SDL::Tutorial::Tetris::Model::Pieces

Download:
SDL-Tutorial-Tetris-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME SDL::Tutorial::Tetris::Model::Pieces - the tetris pieces ^

SYNOPSIS ^

    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";
    }

DESCRIPTION ^

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).

random

Returns a random piece and rotation.

init_xy

Returns the initial (x,y) coordinates for each block and rotation.

block_color

Given a block, rotation, and (x,y) coordinates, it returns the color of the block in that point.

syntax highlighting: