Frame 1
pourcentageTxt.text = "";
Frame 2
stop();
pourcentageTxt.text = "";
_root.onEnterFrame = function () {
sofar = this.getBytesLoaded();
total = this.getBytesTotal();
pourcentageTxt.text = Math.floor((sofar / total) * 100) + "%";
if (sofar == total) {
delete _root.onEnterFrame;
play();
}
};
Frame 4
function catchKey() {
var _local1 = Key.getCode();
switch (_local1) {
case 49 :
onePlayerGame();
break;
case 50 :
twoPlayerGame();
break;
case 79 :
options();
}
}
function onePlayerGame() {
textIntro.btnOnePlayer.enabled = false;
Key.removeListener(this);
sChoix = "1 Player";
gotoAndPlay (13);
}
function twoPlayerGame() {
textIntro.btnTwoPlayers.enabled = false;
Key.removeListener(this);
sChoix = "2 Players";
gotoAndPlay (13);
}
function options() {
textIntro.btnOptions.enabled = false;
Key.removeListener(this);
sChoix = "Options";
gotoAndPlay (13);
}
stop();
var nPlayers = 0;
var sPlayerName1 = "Player1";
var nLevel1 = 0;
var nHandicap1 = 0;
var nMatchPoint1 = 0;
var sPlayerName2 = "Player2";
var nLevel2 = 0;
var nHandicap2 = 0;
var nMatchPoint2 = 0;
var sChoix = "Options";
Key.removeListener(this);
Key.addListener(this);
this.onKeyDown = catchKey;
textIntro.btnOnePlayer.onPress = function () {
onePlayerGame();
};
textIntro.btnTwoPlayers.onPress = function () {
twoPlayerGame();
};
textIntro.btnOptions.onPress = function () {
options();
};
Frame 5
gotoAndStop (4);
Frame 31
switch (sChoix) {
case "1 Player" :
nPlayers = 1;
gotoAndPlay (102);
break;
case "2 Players" :
nPlayers = 2;
gotoAndPlay (102);
break;
case "Options" :
gotoAndPlay (32);
}
Frame 54
function catchKey() {
var _local2 = Key.getCode();
Key.removeListener(this);
switch (_local2) {
case 66 :
gotoAndPlay (61);
break;
default :
Key.addListener(this);
}
}
textOptions.btnBack.onPress = function () {
this.enabled = false;
gotoAndPlay (61);
};
Key.removeListener(this);
Key.addListener(this);
this.onKeyDown = catchKey;
Frame 55
gotoAndStop (54);
Frame 101
gotoAndStop (4);
Frame 122
switch (sChoix) {
case "1 Player" :
gotoAndStop (123);
break;
case "2 Players" :
gotoAndStop (125);
}
Frame 123
Frame 124
gotoAndStop (123);
Frame 125
Frame 126
gotoAndStop (125);
Frame 127
function reinitiateGame() {
btnPause.enabled = true;
btnPause._alpha = 100;
if (nPlayers == 1) {
player1.reinitiateGame();
player1.jumpToLevel(nLevel1);
player1.handicap(nHandicap1);
} else {
player1.reinitiateGame();
player2.reinitiateGame();
player1.jumpToLevel(nLevel1);
player2.jumpToLevel(nLevel2);
player1.handicap(nHandicap1);
player2.handicap(nHandicap2);
player1.setMultiplayer();
player2.setMultiplayer();
player1.setStars(nPlayer1Stars);
player2.setStars(nPlayer2Stars);
}
bGameInitiated = true;
startGame();
}
function startGame() {
nTimerGame = setInterval(game, 50);
var i = 1;
while (i <= nPlayers) {
eval ("player" + i).startGame();
i++;
}
}
function game() {
if (isGameOver()) {
endGame();
}
if (nPlayers > 1) {
if (player2.nDelay <= 0) {
player2.applyAttack(player1.nAttack);
player1.nAttack = 0;
}
if (player1.nDelay <= 0) {
player1.applyAttack(player2.nAttack);
player2.nAttack = 0;
}
}
}
function catchKey() {
var keyCode = Key.getCode();
switch (keyCode) {
case 88 :
showMsgBoxQuit();
break;
case 89 :
if (bMsgBoxOpened) {
quitGame();
}
break;
case 78 :
if (bMsgBoxOpened) {
dontQuitGame();
}
break;
case 13 :
btnContinueHandler();
}
if (isGameOver()) {
return(undefined);
}
if (!(keyCode === 80)) {
} else {
pauseGame();
}
var i = 1;
while (i <= nPlayers) {
if ((!eval ("player" + i).bPaused) && (!eval ("player" + i).bGameOver)) {
switch (keyCode) {
case eval ("player" + i).keyLeft :
eval ("player" + i).moveLeft();
break;
case eval ("player" + i).keyRight :
eval ("player" + i).moveRight();
break;
case eval ("player" + i).keyMoveDown :
eval ("player" + i).moveDown();
break;
case eval ("player" + i).keyDrop :
eval ("player" + i).dropDown();
break;
case eval ("player" + i).keyRotate :
eval ("player" + i).rotate();
}
}
i++;
}
updateAfterEvent();
}
function isGameOver() {
var i = 1;
while (i <= nPlayers) {
if (eval ("player" + i).bGameOver) {
return(true);
}
i++;
}
}
function endGame() {
clearInterval(nTimerGame);
btnPause.enabled = false;
btnPause._alpha = 50;
if (nPlayers > 1) {
var i = 1;
while (i <= nPlayers) {
eval ("player" + i).stopGame();
if (eval ("player" + i).bGameOver) {
eval ("player" + i).lose();
} else {
eval ("player" + i).win();
if (i == 1) {
nPlayer1Stars++;
} else {
nPlayer2Stars++;
}
}
if (eval ("player" + i).nStars > 1) {
nMatchWinner = i;
if (i == 1) {
nMatchPoint1++;
}
if (i == 2) {
nMatchPoint2++;
}
}
i++;
}
} else {
player1.stopGame();
player1.gameover();
}
_root.attachMovie("mcContinue", "mcContinue", _root.getNextHighestDepth(), {_x:0, _y:26});
mcContinue.btnContinue.onPress = function () {
btnContinueHandler();
};
}
function destroyPlayers() {
var i = 1;
while (i <= nPlayers) {
eval ("player" + i).destroy();
eval (("player" + i) + " = null");
i++;
}
}
function pauseGame() {
if (bMsgBoxOpened) {
return(undefined);
}
if (isGameOver()) {
return(undefined);
}
bGamePaused = !bGamePaused;
var i = 1;
while (i <= nPlayers) {
if (eval ("player" + i).bPaused) {
eval ("player" + i).startGame();
} else {
eval ("player" + i).pauseGame();
}
i++;
}
}
function btnContinueHandler() {
if (isGameOver() && (!bMsgBoxOpened)) {
mcContinue.removeMovieClip();
if (nPlayers == 1) {
quitGame();
} else if (nMatchWinner > 0) {
quitGame();
} else {
reinitiateGame();
}
}
}
function showMsgBoxQuit() {
if (!bGamePaused) {
pauseGame();
}
if (bMsgBoxOpened) {
return(undefined);
}
bMsgBoxOpened = true;
btnPause.enabled = false;
btnPause._alpha = 50;
btnQuit.enabled = false;
btnQuit._alpha = 50;
_root.attachMovie("mcMsgBoxQuit", "mcMsgBoxQuit", _root.getNextHighestDepth(), {_x:0, _y:0});
mcMsgBoxQuit._x = (Stage.width / 2) - (mcMsgBoxQuit._width / 2);
mcMsgBoxQuit._y = (Stage.height / 2) - (mcMsgBoxQuit._height / 2);
mcMsgBoxQuit.btnYes.onPress = function () {
quitGame();
};
mcMsgBoxQuit.btnNo.onPress = function () {
dontQuitGame();
};
}
function dontQuitGame() {
mcMsgBoxQuit.removeMovieClip();
if (!isGameOver()) {
btnPause.enabled = true;
btnPause._alpha = 100;
}
btnQuit.enabled = true;
btnQuit._alpha = 100;
bMsgBoxOpened = false;
pauseGame();
}
function quitGame() {
mcMsgBoxQuit.removeMovieClip();
mcContinue.removeMovieClip();
Key.removeListener(this);
clearInterval(nTimerGame);
bGameInitiated = false;
destroyPlayers();
gotoAndPlay (102);
}
stop();
var nTimerGame;
var bGameInitiated;
var bMsgBoxOpened = false;
var bGamePaused = false;
var nPlayer1Stars = 0;
var nPlayer2Stars = 0;
var nMatchWinner = 0;
if (!bGameInitiated) {
destroyPlayers();
if (nPlayers == 1) {
var player1 = new Player(sPlayerName1, 175, 35);
player1.setKeys(37, 39, 40, 38);
player1.jumpToLevel(nLevel1);
player1.handicap(nHandicap1);
} else {
var player1 = new Player(sPlayerName1, 280, 35);
var player2 = new Player(sPlayerName2, 10, 35);
player1.setKeys(37, 39, 40, 38, 46);
player2.setKeys(65, 68, 83, 87, 81);
player1.jumpToLevel(nLevel1);
player2.jumpToLevel(nLevel2);
player1.handicap(nHandicap1);
player2.handicap(nHandicap2);
player1.setMultiplayer();
player2.setMultiplayer();
}
bGameInitiated = true;
startGame();
}
Key.removeListener(this);
Key.addListener(this);
this.onKeyDown = catchKey;
btnPause.onPress = function () {
pauseGame();
};
btnQuit.onPress = function () {
showMsgBoxQuit();
};
Frame 128
gotoAndStop (127);
Symbol 28 MovieClip Frame 10
stop();
Symbol 31 MovieClip [GameoverClip] Frame 20
stop();
Symbol 33 MovieClip [LoseClip] Frame 20
stop();
Symbol 35 MovieClip [WinClip] Frame 20
stop();
Symbol 39 MovieClip [NextBlockClip] Frame 17
stop();
Symbol 39 MovieClip [NextBlockClip] Frame 33
stop();
Symbol 39 MovieClip [NextBlockClip] Frame 49
stop();
Symbol 41 MovieClip [NextBlockSurprise] Frame 11
gotoAndPlay (1);
Symbol 46 MovieClip Frame 11
gotoAndPlay (1);
Symbol 76 MovieClip [Trophy anim] Frame 25
stop();
Symbol 95 Button
on (press) {
this.getURL("http://www.francoisauger.com/tetris");
}
Symbol 155 MovieClip [__Packages.Player] Frame 0
class Player
{
var sName, nBoardPosX, nBoardPosY, aLastShape, nScore, nLines, nLevel, nSpeed, bPaused, nAttack, nDelay, bMultiplayer, nStars, nNextShape, nShape, nRotation, nPosX, nPosY, bNotMoved, mcStatsBoard, bGameOver, aBoard, mcBoard, aShapes, mcNextShapeBoard, keyLeft, keyRight, keyMoveDown, keyDrop, keyRotate, nTimerBlockFall, nFillCounter, nTimerFillBoard;
function Player (param_sName, param_nBoardPosX, param_nBoardPosY) {
sName = param_sName;
nBoardPosX = param_nBoardPosX;
nBoardPosY = param_nBoardPosY;
aLastShape = new Array();
nScore = 0;
nLines = 0;
nLevel = 0;
nSpeed = 500;
bPaused = true;
nAttack = 0;
nDelay = 0;
bMultiplayer = false;
nStars = 0;
initShapes();
initBoard();
initNextShapeBoard();
initStatsBoard();
nNextShape = int(Math.random() * 7);
nShape = nNextShape;
nRotation = 0;
nPosX = 3;
nPosY = -1;
bNotMoved = true;
drawShape();
drawNextShape();
drawStats();
}
function setMultiplayer() {
bMultiplayer = true;
mcStatsBoard.StatsBoard.mcStarBoard._visible = true;
}
function reinitiateGame() {
nScore = 0;
nLines = 0;
nLevel = 0;
nSpeed = 500;
bPaused = true;
nAttack = 0;
nDelay = 0;
bGameOver = false;
var _local4 = 0;
while (_local4 < 18) {
var _local2 = 0;
while (_local2 < 10) {
aBoard[_local2][_local4] = 0;
_local2++;
}
_local4++;
}
_local4 = 0;
while (_local4 < 18) {
var _local2 = 0;
while (_local2 < 10) {
var _local3 = (_local4 * 10) + _local2;
mcBoard[_local3]._x = _local2 * 20;
mcBoard[_local3]._y = _local4 * 20;
mcBoard[_local3].mcExplosion.gotoAndStop(1);
_local2++;
}
_local4++;
}
mcBoard.Board.mcBoardBG.mcColones._visible = false;
nNextShape = int(Math.random() * 7);
nShape = nNextShape;
nRotation = 0;
nPosX = 3;
nPosY = -1;
bNotMoved = true;
mcBoard.GameoverClip.removeMovieClip();
drawShape();
drawNextShape();
drawStats();
}
function initShapes() {
aShapes = [];
var _local4 = 0;
while (_local4 < 40) {
aShapes[_local4] = [];
var _local3 = 0;
while (_local3 < 4) {
aShapes[_local4][_local3] = [];
var _local2 = 0;
while (_local2 < 4) {
aShapes[_local4][_local3][_local2] = 0;
_local2++;
}
_local3++;
}
_local4++;
}
aShapes[0][0][1] = 5;
aShapes[0][0][2] = 5;
aShapes[0][1][1] = 5;
aShapes[0][2][1] = 5;
aShapes[1][0][1] = 5;
aShapes[1][1][1] = 5;
aShapes[1][1][2] = 5;
aShapes[1][1][3] = 5;
aShapes[2][2][1] = 5;
aShapes[2][2][2] = 5;
aShapes[2][1][2] = 5;
aShapes[2][0][2] = 5;
aShapes[3][0][1] = 5;
aShapes[3][0][2] = 5;
aShapes[3][0][3] = 5;
aShapes[3][1][3] = 5;
aShapes[4][2][2] = 6;
aShapes[4][2][1] = 6;
aShapes[4][1][1] = 6;
aShapes[4][0][1] = 6;
aShapes[5][1][1] = 6;
aShapes[5][1][2] = 6;
aShapes[5][1][3] = 6;
aShapes[5][0][3] = 6;
aShapes[6][0][2] = 6;
aShapes[6][0][1] = 6;
aShapes[6][1][2] = 6;
aShapes[6][2][2] = 6;
aShapes[7][1][1] = 6;
aShapes[7][0][1] = 6;
aShapes[7][0][2] = 6;
aShapes[7][0][3] = 6;
aShapes[8][1][1] = 2;
aShapes[8][0][2] = 2;
aShapes[8][1][2] = 2;
aShapes[8][2][2] = 2;
aShapes[9][0][1] = 2;
aShapes[9][0][2] = 2;
aShapes[9][1][2] = 2;
aShapes[9][0][3] = 2;
aShapes[10][0][1] = 2;
aShapes[10][1][1] = 2;
aShapes[10][2][1] = 2;
aShapes[10][1][2] = 2;
aShapes[11][1][1] = 2;
aShapes[11][0][2] = 2;
aShapes[11][1][2] = 2;
aShapes[11][1][3] = 2;
aShapes[12][0][1] = 7;
aShapes[12][1][1] = 7;
aShapes[12][2][1] = 7;
aShapes[12][3][1] = 7;
aShapes[13][1][0] = 7;
aShapes[13][1][1] = 7;
aShapes[13][1][2] = 7;
aShapes[13][1][3] = 7;
aShapes[14][0][1] = 7;
aShapes[14][1][1] = 7;
aShapes[14][2][1] = 7;
aShapes[14][3][1] = 7;
aShapes[15][1][0] = 7;
aShapes[15][1][1] = 7;
aShapes[15][1][2] = 7;
aShapes[15][1][3] = 7;
aShapes[16][1][1] = 1;
aShapes[16][2][1] = 1;
aShapes[16][1][2] = 1;
aShapes[16][2][2] = 1;
aShapes[17][1][1] = 1;
aShapes[17][2][1] = 1;
aShapes[17][1][2] = 1;
aShapes[17][2][2] = 1;
aShapes[18][1][1] = 1;
aShapes[18][2][1] = 1;
aShapes[18][1][2] = 1;
aShapes[18][2][2] = 1;
aShapes[19][1][1] = 1;
aShapes[19][2][1] = 1;
aShapes[19][1][2] = 1;
aShapes[19][2][2] = 1;
aShapes[20][0][1] = 3;
aShapes[20][1][1] = 3;
aShapes[20][1][2] = 3;
aShapes[20][2][2] = 3;
aShapes[21][1][1] = 3;
aShapes[21][0][2] = 3;
aShapes[21][1][2] = 3;
aShapes[21][0][3] = 3;
aShapes[22][0][1] = 3;
aShapes[22][1][1] = 3;
aShapes[22][1][2] = 3;
aShapes[22][2][2] = 3;
aShapes[23][1][1] = 3;
aShapes[23][0][2] = 3;
aShapes[23][1][2] = 3;
aShapes[23][0][3] = 3;
aShapes[24][1][1] = 4;
aShapes[24][2][1] = 4;
aShapes[24][0][2] = 4;
aShapes[24][1][2] = 4;
aShapes[25][0][1] = 4;
aShapes[25][0][2] = 4;
aShapes[25][1][2] = 4;
aShapes[25][1][3] = 4;
aShapes[26][1][1] = 4;
aShapes[26][2][1] = 4;
aShapes[26][0][2] = 4;
aShapes[26][1][2] = 4;
aShapes[27][0][1] = 4;
aShapes[27][0][2] = 4;
aShapes[27][1][2] = 4;
aShapes[27][1][3] = 4;
aShapes[28][0][0] = 4;
aShapes[28][1][1] = 4;
aShapes[28][2][2] = 4;
aShapes[28][3][3] = 4;
aShapes[28][3][0] = 4;
aShapes[29][3][0] = 4;
aShapes[29][2][1] = 4;
aShapes[29][1][2] = 4;
aShapes[29][0][3] = 4;
aShapes[29][3][3] = 4;
aShapes[30][0][0] = 4;
aShapes[30][1][1] = 4;
aShapes[30][2][2] = 4;
aShapes[30][3][3] = 4;
aShapes[30][0][3] = 4;
aShapes[31][3][0] = 4;
aShapes[31][2][1] = 4;
aShapes[31][1][2] = 4;
aShapes[31][0][3] = 4;
aShapes[31][0][0] = 4;
aShapes[32][0][0] = 4;
aShapes[32][0][1] = 4;
aShapes[32][0][2] = 4;
aShapes[32][2][0] = 4;
aShapes[32][3][0] = 4;
aShapes[32][3][1] = 4;
aShapes[33][1][0] = 4;
aShapes[33][2][0] = 4;
aShapes[33][3][0] = 4;
aShapes[33][3][2] = 4;
aShapes[33][3][3] = 4;
aShapes[33][2][3] = 4;
aShapes[34][3][1] = 4;
aShapes[34][3][2] = 4;
aShapes[34][3][3] = 4;
aShapes[34][0][2] = 4;
aShapes[34][0][3] = 4;
aShapes[34][1][3] = 4;
aShapes[35][0][0] = 4;
aShapes[35][1][0] = 4;
aShapes[35][0][1] = 4;
aShapes[35][0][3] = 4;
aShapes[35][1][3] = 4;
aShapes[35][2][3] = 4;
aShapes[36][0][0] = 4;
aShapes[36][2][0] = 4;
aShapes[36][3][1] = 4;
aShapes[36][0][2] = 4;
aShapes[36][1][3] = 4;
aShapes[36][3][3] = 4;
aShapes[37][1][0] = 4;
aShapes[37][3][0] = 4;
aShapes[37][0][1] = 4;
aShapes[37][3][2] = 4;
aShapes[37][0][3] = 4;
aShapes[37][2][3] = 4;
aShapes[38][0][0] = 4;
aShapes[38][2][0] = 4;
aShapes[38][3][1] = 4;
aShapes[38][0][2] = 4;
aShapes[38][1][3] = 4;
aShapes[38][3][3] = 4;
aShapes[39][1][0] = 4;
aShapes[39][3][0] = 4;
aShapes[39][0][1] = 4;
aShapes[39][3][2] = 4;
aShapes[39][0][3] = 4;
aShapes[39][2][3] = 4;
}
function initBoard() {
mcBoard = _root.createEmptyMovieClip(sName, _root.getNextHighestDepth());
mcBoard.attachMovie("Board", "Board", mcBoard.getNextHighestDepth(), {_x:0, _y:0});
mcBoard.Board.TextPlayerName.text = sName;
mcBoard.Board.mcBoardBG.mcColones._visible = false;
mcBoard.Board.mcPause._visible = false;
mcBoard._x = nBoardPosX;
mcBoard._y = nBoardPosY;
aBoard = [];
var _local3 = 0;
while (_local3 < 10) {
aBoard[_local3] = [];
var _local5 = 0;
while (_local5 < 18) {
aBoard[_local3][_local5] = 0;
_local5++;
}
_local3++;
}
var _local5 = 0;
while (_local5 < 18) {
_local3 = 0;
while (_local3 < 10) {
var _local4 = (_local5 * 10) + _local3;
mcBoard.attachMovie("Block", _local4, mcBoard.getNextHighestDepth(), {_x:_local3 * 20, _y:_local5 * 20});
mcBoard[_local4].gotoAndStop(1);
mcBoard[_local4].mcExplosion.gotoAndStop(1);
_local3++;
}
_local5++;
}
}
function initNextShapeBoard() {
mcNextShapeBoard = _root.createEmptyMovieClip(sName + "NextShape", _root.getNextHighestDepth());
mcNextShapeBoard.attachMovie("NextBlockBoard", "NextBlockBoard", mcNextShapeBoard.getNextHighestDepth(), {_x:0, _y:0});
mcNextShapeBoard._x = (nBoardPosX + 200) + 10;
mcNextShapeBoard._y = nBoardPosY;
var _local5 = 0;
while (_local5 < 4) {
var _local3 = 0;
while (_local3 < 4) {
var _local4 = (_local5 * 4) + _local3;
mcNextShapeBoard.attachMovie("NextBlockClip", _local4, mcNextShapeBoard.getNextHighestDepth(), {_x:_local3 * 13, _y:_local5 * 13});
mcNextShapeBoard[_local4].gotoAndStop(1);
_local3++;
}
_local5++;
}
}
function initStatsBoard() {
mcStatsBoard = _root.createEmptyMovieClip(sName + "Stats", _root.getNextHighestDepth());
mcStatsBoard._x = (nBoardPosX + 200) + 10;
mcStatsBoard._y = nBoardPosY + 61;
mcStatsBoard.attachMovie("StatsBoard", "StatsBoard", mcStatsBoard.getNextHighestDepth(), {_x:0, _y:0});
mcStatsBoard.StatsBoard.mcStarBoard._visible = false;
mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndStop(1);
mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = false;
mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndStop(1);
mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = false;
}
function setKeys(param_keyLeft, param_keyRight, param_keyDrop, param_keyRotate, param_keyMoveDown) {
keyLeft = param_keyLeft;
keyRight = param_keyRight;
keyMoveDown = param_keyMoveDown;
keyDrop = param_keyDrop;
keyRotate = param_keyRotate;
}
function startGame() {
if (bPaused) {
bPaused = false;
var _local4 = 0;
while (_local4 < 18) {
var _local2 = 0;
while (_local2 < 10) {
var _local3 = (_local4 * 10) + _local2;
mcBoard[_local3]._visible = true;
_local2++;
}
_local4++;
}
mcBoard.Board.mcPause._visible = false;
moveDown();
}
clearInterval(nTimerBlockFall);
nTimerBlockFall = setInterval(this, "blockFall", nSpeed);
}
function pauseGame() {
bPaused = true;
clearInterval(nTimerBlockFall);
var _local4 = 0;
while (_local4 < 18) {
var _local2 = 0;
while (_local2 < 10) {
var _local3 = (_local4 * 10) + _local2;
mcBoard[_local3]._visible = false;
_local2++;
}
_local4++;
}
mcBoard.Board.mcPause._visible = true;
mcBoard.Board.mcPause.gotoAndPlay(1);
}
function stopGame() {
clearInterval(nTimerBlockFall);
}
function blockFall() {
if (isDelayed()) {
return(undefined);
}
moveDown();
updateAfterEvent();
}
function isDelayed() {
if (nDelay <= 0) {
return(false);
}
if ((--nDelay) == 0) {
clearFullLines();
}
return(true);
}
function moveLeft() {
if (nDelay > 0) {
return(undefined);
}
if (!collision(nPosX - 1, nPosY, nRotation)) {
nPosX--;
drawShape();
}
}
function moveRight() {
if (nDelay > 0) {
return(undefined);
}
if (!collision(nPosX + 1, nPosY, nRotation)) {
nPosX++;
drawShape();
}
}
function rotate() {
if (nDelay > 0) {
return(undefined);
}
var _local2 = nRotation + 1;
if (_local2 > 3) {
_local2 = 0;
}
if (!collision(nPosX, nPosY, _local2)) {
nRotation = _local2;
drawShape();
}
}
function dropDown() {
if (nDelay > 0) {
return(undefined);
}
while (true) {
if (!collision(nPosX, nPosY + 1, nRotation)) {
nPosY++;
nScore++;
} else {
drawShape();
break;
}
}
moveDown();
}
function moveDown() {
if (nDelay > 0) {
return(undefined);
}
if (!collision(nPosX, nPosY + 1, nRotation)) {
nPosY++;
drawShape();
nScore++;
} else {
checkLines();
nShape = nNextShape;
nRotation = 0;
nPosX = 3;
nPosY = -99;
var _local3 = 0;
while (_local3 < 4) {
var _local2 = 0;
while (_local2 < 4) {
if ((aShapes[(nShape * 4) + nRotation][_local2][_local3] != 0) && (nPosY == -99)) {
nPosY = -_local3;
}
_local2++;
}
_local3++;
}
bNotMoved = true;
nNextShape = int(Math.random() * 7);
drawShape();
drawNextShape();
drawStats();
if (collision(nPosX, nPosY, nRotation)) {
gameOver();
}
}
}
function collision(param_nPosX, param_nPosY, param_nRotation) {
var _local5 = 0;
while (_local5 < 4) {
var _local2 = 0;
while (_local2 < 4) {
if (aShapes[(nShape * 4) + param_nRotation][_local2][_local5] != 0) {
var _local3 = _local2 + param_nPosX;
var _local4 = _local5 + param_nPosY;
if (((_local3 < 0) || (_local3 > 9)) || (_local4 > 17)) {
return(true);
}
if (aBoard[_local3][_local4] != 0) {
return(true);
}
}
_local2++;
}
_local5++;
}
}
function checkLines() {
var _local3 = 0;
while (_local3 < 4) {
var _local2 = 0;
while (_local2 < 4) {
if (aShapes[(nShape * 4) + nRotation][_local2][_local3] != 0) {
var _local5 = _local2 + nPosX;
var _local4 = _local3 + nPosY;
aBoard[_local5][_local4] = aShapes[(nShape * 4) + nRotation][_local2][_local3];
}
_local2++;
}
_local3++;
}
var _local7 = 0;
_local3 = 0;
while (_local3 < 18) {
var _local6 = false;
var _local2 = 0;
while (_local2 < 10) {
if (aBoard[_local2][_local3] == 0) {
_local6 = true;
}
_local2++;
}
if (!_local6) {
_local2 = 0;
while (_local2 < 10) {
mcBoard[(_local3 * 10) + _local2].mcExplosion.gotoAndPlay(2);
_local2++;
}
_local7++;
}
_local3++;
}
if (_local7 > 0) {
switch (_local7) {
case 1 :
nScore = nScore + 40;
nDelay = 1;
break;
case 2 :
nScore = nScore + 100;
nDelay = 1;
break;
case 3 :
nScore = nScore + 300;
nDelay = 1;
break;
case 4 :
nScore = nScore + 1200;
nDelay = 2;
applyBonus();
}
nAttack = _local7;
nLines = nLines + _local7;
if (Math.floor(nLines / 10) > nLevel) {
nLevel = Math.floor(nLines / 10);
}
if (nLevel > 9) {
nLevel = 9;
}
ajustSpeed();
startGame();
}
}
function clearFullLines() {
var _local5 = 0;
while (_local5 < 18) {
var _local6 = false;
var _local4 = 0;
while (_local4 < 10) {
if (aBoard[_local4][_local5] == 0) {
_local6 = true;
}
_local4++;
}
if (!_local6) {
var _local3 = _local5;
while (_local3 >= 0) {
var _local2 = 0;
while (_local2 < 10) {
if (_local3 == 0) {
aBoard[_local2][_local3] = 0;
} else {
aBoard[_local2][_local3] = aBoard[_local2][_local3 - 1];
}
mcBoard[(_local3 * 10) + _local2].mcExplosion.gotoAndStop(1);
_local2++;
}
_local3--;
}
}
_local5++;
}
fullBoardRedraw();
}
function applyAttack(param_nAttack) {
if (param_nAttack == 0) {
return(undefined);
}
switch (param_nAttack) {
case 2 :
var _local4 = 0;
while (_local4 < 17) {
var _local2 = 0;
while (_local2 < 10) {
aBoard[_local2][_local4] = aBoard[_local2][_local4 + 1];
_local2++;
}
_local4++;
}
var _local5 = Math.floor(Math.random() * 10);
var _local2 = 0;
while (_local2 < 10) {
if (_local2 == _local5) {
aBoard[_local2][17] = 0;
} else {
aBoard[_local2][17] = 25;
}
_local2++;
}
break;
case 3 :
_local4 = 0;
while (_local4 < 16) {
_local2 = 0;
while (_local2 < 10) {
aBoard[_local2][_local4] = aBoard[_local2][_local4 + 2];
_local2++;
}
_local4++;
}
_local5 = Math.floor(Math.random() * 10);
_local2 = 0;
while (_local2 < 10) {
_local4 = 16;
while (_local4 < 18) {
if (_local2 == _local5) {
aBoard[_local2][_local4] = 0;
} else {
aBoard[_local2][_local4] = 25;
}
_local4++;
}
_local2++;
}
break;
case 4 :
mcBoard.Board.mcBoardBG.mcColones._visible = false;
switch (Math.floor(Math.random() * 6)) {
case 0 :
_local4 = 0;
while (_local4 < 15) {
_local2 = 0;
while (_local2 < 10) {
aBoard[_local2][_local4] = aBoard[_local2][_local4 + 3];
_local2++;
}
_local4++;
}
_local5 = Math.floor(Math.random() * 10);
_local2 = 0;
while (_local2 < 10) {
_local4 = 15;
while (_local4 < 18) {
if ((_local2 == _local5) || (Math.floor(Math.random() * 10) > 5)) {
aBoard[_local2][_local4] = 0;
} else {
aBoard[_local2][_local4] = 25;
}
_local4++;
}
_local2++;
}
break;
case 1 :
nNextShape = 7;
drawNextShapeSurprise();
break;
case 2 :
nNextShape = 8;
drawNextShapeSurprise();
break;
case 3 :
nNextShape = 9;
drawNextShapeSurprise();
break;
case 4 :
_local4 = 0;
while (_local4 < 18) {
_local2 = 0;
while (_local2 < 10) {
var _local3 = (_local4 * 10) + _local2;
mcBoard[_local3]._x = 180 - (_local2 * 20);
mcBoard[_local3]._y = 340 - (_local4 * 20);
_local2++;
}
_local4++;
}
break;
case 5 :
_local4 = 0;
for(;;){
if (_local4 >= 18) {
break;
}
_local2 = 0;
while (_local2 < 10) {
if (_local2 % 2) {
aBoard[_local2][_local4] = 0;
}
_local2++;
}
_local4++;
};
}
}
fullBoardRedraw();
}
function applyBonus() {
var _local4 = 0;
while (_local4 < 18) {
var _local2 = 0;
while (_local2 < 10) {
var _local3 = (_local4 * 10) + _local2;
mcBoard[_local3]._x = _local2 * 20;
mcBoard[_local3]._y = _local4 * 20;
_local2++;
}
_local4++;
}
mcBoard.Board.mcBoardBG.mcColones._visible = true;
fullBoardRedraw();
}
function drawShape() {
if (bNotMoved) {
bNotMoved = false;
} else {
var _local8 = aLastShape.length;
var _local7 = 0;
while (_local7 < _local8) {
mcBoard[aLastShape[_local7]].gotoAndStop(1);
_local7++;
}
}
aLastShape = [];
var _local7 = 0;
var _local5 = 0;
while (_local5 < 4) {
var _local2 = 0;
while (_local2 < 4) {
var _local6;
_local6 = aShapes[(nShape * 4) + nRotation][_local2][_local5];
if (_local6 != 0) {
var _local4 = _local2 + nPosX;
var _local3 = _local5 + nPosY;
mcBoard[(_local3 * 10) + _local4].gotoAndStop(_local6 + 1);
aLastShape[_local7++] = (_local3 * 10) + _local4;
}
_local2++;
}
_local5++;
}
}
function fullBoardRedraw() {
var _local3 = 0;
while (_local3 < 18) {
var _local2 = 0;
while (_local2 < 10) {
mcBoard[(_local3 * 10) + _local2].gotoAndStop(aBoard[_local2][_local3] + 1);
_local2++;
}
_local3++;
}
_local3 = 0;
while (_local3 < 4) {
var _local2 = 0;
while (_local2 < 4) {
var _local6;
_local6 = aShapes[(nShape * 4) + nRotation][_local2][_local3];
if (_local6 != 0) {
var _local5 = _local2 + nPosX;
var _local4 = _local3 + nPosY;
mcBoard[(_local4 * 10) + _local5].gotoAndStop(_local6 + 1);
}
_local2++;
}
_local3++;
}
}
function drawNextShape() {
var _local4 = 0;
while (_local4 < 16) {
mcNextShapeBoard[_local4].gotoAndStop(1);
_local4++;
}
mcNextShapeBoard.NextBlockSurprise.removeMovieClip();
var _local5 = (int(Math.random() * 3) * 16) + 2;
var _local3 = 0;
while (_local3 < 4) {
var _local2 = 0;
while (_local2 < 4) {
if (aShapes[(nNextShape * 4) + nRotation][_local2][_local3] > 0) {
mcNextShapeBoard[(_local3 * 4) + _local2].gotoAndPlay(_local5);
}
_local2++;
}
_local3++;
}
}
function drawNextShapeSurprise() {
var _local2 = 0;
while (_local2 < 16) {
mcNextShapeBoard[_local2].gotoAndStop(1);
_local2++;
}
mcNextShapeBoard.attachMovie("NextBlockSurprise", "NextBlockSurprise", mcBoard.getNextHighestDepth(), {_x:0, _y:0});
mcNextShapeBoard.NextBlockSurprise._x = 13;
mcNextShapeBoard.NextBlockSurprise._y = 6;
}
function drawStats() {
mcStatsBoard.StatsBoard.TextLevel.text = nLevel;
mcStatsBoard.StatsBoard.TextScore.text = nScore;
mcStatsBoard.StatsBoard.TextLines.text = nLines;
}
function gameOver() {
bGameOver = true;
stopGame();
nFillCounter = 179;
}
function fillBoard() {
var _local2 = 0;
while (_local2 < 10) {
mcBoard[nFillCounter--].gotoAndStop(25);
_local2++;
}
if (nFillCounter < 0) {
clearInterval(nTimerFillBoard);
}
updateAfterEvent();
}
function gameover() {
mcBoard.attachMovie("GameoverClip", "GameoverClip", mcBoard.getNextHighestDepth(), {_x:0, _y:0});
}
function win() {
mcBoard.attachMovie("WinClip", "GameoverClip", mcBoard.getNextHighestDepth(), {_x:0, _y:0});
nStars++;
if (nStars == 1) {
mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = true;
mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndPlay(1);
}
if (nStars == 2) {
mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = true;
mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndPlay(1);
mcBoard.attachMovie("Trophy anim", "Trophy anim", mcBoard.getNextHighestDepth(), {_x:56, _y:230});
}
}
function setStars(nNumStars) {
nStars = nNumStars;
if (nStars < 0) {
nStars = 0;
}
if (nStars > 2) {
nStars = 2;
}
if (nStars >= 1) {
mcStatsBoard.StatsBoard.mcStarBoard.mcStar1._visible = true;
mcStatsBoard.StatsBoard.mcStarBoard.mcStar1.gotoAndStop(1);
}
if (nStars >= 2) {
mcStatsBoard.StatsBoard.mcStarBoard.mcStar2._visible = true;
mcStatsBoard.StatsBoard.mcStarBoard.mcStar2.gotoAndStop(1);
}
}
function lose() {
mcBoard.attachMovie("LoseClip", "GameoverClip", mcBoard.getNextHighestDepth(), {_x:0, _y:0});
}
function destroy() {
mcBoard.removeMovieClip();
mcNextShapeBoard.removeMovieClip();
mcStatsBoard.removeMovieClip();
}
function ajustSpeed() {
nSpeed = 500 - (nLevel * 40);
}
function jumpToLevel(param_nLevel) {
nLevel = param_nLevel;
ajustSpeed();
drawStats();
}
function handicap(param_nHandicap) {
var _local4 = Math.floor(Math.random() * 10);
var _local3 = 0;
while (_local3 < 10) {
var _local2 = 18 - (param_nHandicap * 2);
while (_local2 < 18) {
if ((_local3 == _local4) || (Math.floor(Math.random() * 10) > 5)) {
aBoard[_local3][_local2] = 0;
} else {
aBoard[_local3][_local2] = 25;
}
_local2++;
}
_local3++;
}
fullBoardRedraw();
}
function test(param_nLignes) {
var _local3 = 0;
while (_local3 < 9) {
var _local2 = 18 - param_nLignes;
while (_local2 < 18) {
aBoard[_local3][_local2] = 25;
_local2++;
}
_local3++;
}
nNextShape = 3;
}
}
Symbol 110 Button
on (press) {
gotoAndStop (4);
}
Symbol 113 Button
on (press) {
sPlayerName1 = _root.settings1.playerNameTxt.text;
gotoAndStop (127);
}
Symbol 123 Button
on (press) {
_root.nLevel1--;
if (_root.nLevel1 < 0) {
_root.nLevel1 = 0;
}
levelTxt.text = _root.nLevel1;
}
Symbol 127 Button
on (press) {
_root.nLevel1++;
if (_root.nLevel1 > 9) {
_root.nLevel1 = 9;
}
levelTxt.text = _root.nLevel1;
}
Symbol 129 Button
on (press) {
_root.nHandicap1--;
if (_root.nHandicap1 < 0) {
_root.nHandicap1 = 0;
}
handicapTxt.text = _root.nHandicap1;
}
Symbol 130 Button
on (press) {
_root.nHandicap1++;
if (_root.nHandicap1 > 5) {
_root.nHandicap1 = 5;
}
handicapTxt.text = _root.nHandicap1;
}
Symbol 133 MovieClip Frame 10
stop();
playerNameTxt.text = _root.sPlayerName1;
levelTxt.text = _root.nLevel1;
handicapTxt.text = _root.nHandicap1;
if (_root.nPlayers > 1) {
mcMatchPoint.txtMatchPoint.text = _root.nMatchPoint1;
} else {
mcMatchPoint._visible = false;
}
Symbol 134 Button
on (press) {
if (_root.settings1.playerNameTxt.text != undefined) {
sPlayerName1 = _root.settings1.playerNameTxt.text;
gotoAndStop (127);
}
}
Symbol 137 Button
on (press) {
if ((_root.settings1.playerNameTxt.text != undefined) && (_root.settings2.playerNameTxt.text != undefined)) {
sPlayerName1 = _root.settings1.playerNameTxt.text;
sPlayerName2 = _root.settings2.playerNameTxt.text;
gotoAndStop (127);
}
}
Symbol 142 Button
on (press) {
_root.nLevel2--;
if (_root.nLevel2 < 0) {
_root.nLevel2 = 0;
}
levelTxt.text = _root.nLevel2;
}
Symbol 143 Button
on (press) {
_root.nLevel2++;
if (_root.nLevel2 > 9) {
_root.nLevel2 = 9;
}
levelTxt.text = _root.nLevel2;
}
Symbol 145 Button
on (press) {
_root.nHandicap2--;
if (_root.nHandicap2 < 0) {
_root.nHandicap2 = 0;
}
handicapTxt.text = _root.nHandicap2;
}
Symbol 146 Button
on (press) {
_root.nHandicap2++;
if (_root.nHandicap2 > 5) {
_root.nHandicap2 = 5;
}
handicapTxt.text = _root.nHandicap2;
}
Symbol 147 MovieClip Frame 10
stop();
playerNameTxt.text = _root.sPlayerName2;
levelTxt.text = _root.nLevel2;
handicapTxt.text = _root.nHandicap2;
if (_root.nPlayers > 1) {
mcMatchPoint.txtMatchPoint.text = _root.nMatchPoint2;
} else {
mcMatchPoint._visible = false;
}