Checking for game over

Finally it's time to tell the player the game is over.

The idea: If the tetromino that just appeared on the top of the game field collides with tetrominoes pieces, the game is over.

The development: First we need a new class level variable:

private const TS:uint=24;
private var fieldArray:Array;
private var fieldSprite:Sprite;
private var tetrominoes:Array = new Array();
private var colors:Array=new Array();
private var tetromino:Sprite;
private var currentTetromino:uint;
private var currentRotation:uint;
private var tRow:int;
private var tCol:int;
private var timeCount:Timer=new Timer(500);
private var gameOver:Boolean=false;

gameOver variable will tell us if the game is over (true) or not (false). At the beginning obviously, ...

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.