Removing completed lines

According to game mechanics, a line can be completed only after a tetromino is landed.

The idea: Once the falling tetromino lands on the ground or over another tetromino, we'll check if there is any completed line. A line is completed when it's entirely filled by tetrominoes pieces.

The development: At the end of landTetromino function you should check for completed lines and eventually remove them. Change landTetromino this way:

private function landTetromino():void { var ct:uint=currentTetromino; var landed:Sprite; for (var i:int=0; i<tetrominoes[ct][currentRotation].length; i++) { for (var j:int=0; j<tetrominoes[ct][currentRotation][i].length; j++) { if (tetrominoes[ct][currentRotation][i][j]==1) { landed = new Sprite(); ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.