Frame 2
_root._quality = "LOW";
stop();
stop();
Frame 3
stopAllSounds();
Frame 4
stop();
stopAllSounds();
Frame 5
stop();
Frame 6
stop();
Frame 7
stop();
Frame 8
stop();
Frame 9
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 10
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
stop();
Frame 11
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 12
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 13
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 14
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 15
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 16
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
stop();
Frame 17
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 18
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
Frame 19
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
stop();
stop();
Frame 20
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 35;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 18;
lines = 0;
score = 0;
moviecliplist = new Array();
xx = new Array("1", "2", "3", "4");
yy = new Array("1", "1", "1", "1");
framecount = 0;
var paused = true;
var rotatedcount = 0;
unitmap = new Array();
var i = 0;
while (i < unitwidth) {
unitmap[i] = new Array();
unitmap[i][unitheight + 1] = 1;
i++;
}
mouseListener = new Object();
mouseListener.onMouseDown = function () {
if (paused && (realpaused == false)) {
var _local2 = 0;
while (_local2 <= unitheight) {
var _local1 = 0;
while (_local1 <= unitwidth) {
unitmap[_local1][_local2] = undefined;
_local1++;
}
_local2++;
}
_local2 = 0;
while (_local2 < moviecliplist.length) {
removeMovieClip(moviecliplist[_local2]);
_local2++;
}
startgame();
}
};
Mouse.addListener(mouseListener);
keyListener = new Object();
keyListener.onKeyDown = function () {
var _local2 = Key.getCode();
if (paused) {
if (_local2 == 80) {
paused = false;
}
} else {
if (_local2 == 80) {
realpaused = true;
paused = true;
}
if (_local2 == 38) {
if (piecetype == 0) {
if (rotatedcount == 0) {
if ((((unitmap[xx[0] + 2][yy[0] - 1] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 2] == undefined)) {
xx[0] = xx[0] + 2;
yy[0] = yy[0] - 1;
xx[1] = xx[1] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 2;
rotatedcount++;
}
} else if (((((((unitmap[xx[0] - 2][yy[0] + 1] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2]][yy[2] - 1] == undefined)) && (unitmap[xx[3] + 1][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) && (currentpiece._x != 20)) && (currentpiece._x != 180)) {
xx[0] = xx[0] - 2;
yy[0] = yy[0] + 1;
xx[1] = xx[1] - 1;
yy[2] = yy[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 1) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2] - 2] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] - 2;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3] + 1] == undefined)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 2) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0] - 1] == undefined) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
xx[2] = xx[2] + 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if ((((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2] + 1][yy[2] - 1] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
xx[2] = xx[2] + 1;
yy[2] = yy[2] - 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (((unitmap[xx[0]][yy[0] - 1] == undefined) && (unitmap[xx[2] - 1][yy[2] + 1] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) {
yy[0] = yy[0] - 1;
xx[2] = xx[2] - 1;
yy[2] = yy[2] + 1;
xx[3] = xx[3] - 1;
rotatedcount++;
}
} else if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3] + 1] == undefined)) && (xx[0] != 8)) {
yy[0] = yy[0] + 1;
xx[2] = xx[2] - 1;
xx[3] = xx[3] + 1;
yy[3] = yy[3] + 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 4) {
if (rotatedcount == 0) {
if ((unitmap[xx[0] + 1][yy[0] - 2] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 2;
xx[1] = xx[1] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[0] - 1][yy[0] + 2] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 2;
xx[1] = xx[1] - 1;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 5) {
if (rotatedcount == 0) {
if (((unitmap[xx[0] + 1][yy[0]] == undefined) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] - 2] == undefined)) {
xx[0] = xx[0] + 1;
xx[1] = xx[1] + 1;
yy[3] = yy[3] - 2;
rotatedcount++;
}
} else if ((((unitmap[xx[0] - 1][yy[0]] == undefined) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[3]][yy[3] + 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
xx[1] = xx[1] - 1;
yy[3] = yy[3] + 2;
rotatedcount = 0;
}
reposition();
} else if (piecetype == 6) {
if (rotatedcount == 0) {
if (unitmap[xx[0] + 1][yy[0] - 1] == undefined) {
xx[0] = xx[0] + 1;
yy[0] = yy[0] - 1;
rotatedcount++;
}
} else if (rotatedcount == 1) {
if (((unitmap[xx[0] - 1][yy[0] + 1] == undefined) && (unitmap[xx[2]][yy[2] - 2] == undefined)) && (currentpiece._x != 0)) {
xx[0] = xx[0] - 1;
yy[0] = yy[0] + 1;
yy[2] = yy[2] - 2;
rotatedcount++;
}
} else if (rotatedcount == 2) {
if (unitmap[xx[3] - 1][yy[3] + 1] == undefined) {
xx[3] = xx[3] - 1;
yy[3] = yy[3] + 1;
rotatedcount++;
}
} else if (((unitmap[xx[2]][yy[2] + 2] == undefined) && (unitmap[xx[3] + 1][yy[3] - 1] == undefined)) && (currentpiece._x != 160)) {
yy[2] = yy[2] + 2;
xx[3] = xx[3] + 1;
yy[3] = yy[3] - 1;
rotatedcount = 0;
}
reposition();
}
}
if ((((((((((_local2 == 39) && (current4piece._x != 180)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]++;
_local1++;
}
reposition();
}
if ((((((((((_local2 == 37) && (currentpiece._x != 0)) && (unitmap[xx[0] - 1][yy[0]] == undefined)) && (unitmap[xx[1] - 1][yy[1]] == undefined)) && (unitmap[xx[2] - 1][yy[2]] == undefined)) && (unitmap[xx[3] - 1][yy[3]] == undefined)) && (unitmap[xx[0] + 1][yy[0]] == undefined)) && (unitmap[xx[1] + 1][yy[1]] == undefined)) && (unitmap[xx[2] + 1][yy[2]] == undefined)) && (unitmap[xx[3] + 1][yy[3]] == undefined)) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1]--;
_local1++;
}
reposition();
}
}
};
Key.addListener(keyListener);
gameover = function () {
popup.swapDepths(5000);
popup.gotoAndStop(2);
realpaused = false;
paused = true;
};
reposition = function () {
currentpiece._x = xx[0] * unitsize;
current2piece._x = xx[1] * unitsize;
current3piece._x = xx[2] * unitsize;
current4piece._x = xx[3] * unitsize;
currentpiece._y = yy[0] * unitsize;
current2piece._y = yy[1] * unitsize;
current3piece._y = yy[2] * unitsize;
current4piece._y = yy[3] * unitsize;
};
startgame = function () {
paused = false;
score = 0;
lines = 0;
level = 1;
popup.gotoAndStop(3);
newpiece();
};
newpieceattach = function () {
if ((((unitmap[3][0] != undefined) || (unitmap[4][0] != undefined)) || (unitmap[5][0] != undefined)) || (unitmap[6][0] != undefined)) {
gameover();
} else {
oldlines = 0;
var _local1 = 0;
while (_local1 <= unitheight) {
if ((((((((((unitmap[0][_local1] != undefined) && (unitmap[1][_local1] != undefined)) && (unitmap[2][_local1] != undefined)) && (unitmap[3][_local1] != undefined)) && (unitmap[4][_local1] != undefined)) && (unitmap[5][_local1] != undefined)) && (unitmap[6][_local1] != undefined)) && (unitmap[7][_local1] != undefined)) && (unitmap[8][_local1] != undefined)) && (unitmap[9][_local1] != undefined)) {
var _local3 = 0;
while (_local3 < unitwidth) {
removeMovieClip(unitmap[_local3][_local1]);
var _local2 = 0;
while (_local2 < unitheight) {
unitmap[_local3][_local1 - _local2]._y = unitmap[_local3][_local1 - _local2]._y + unitsize;
unitmap[_local3][_local1 - _local2] = unitmap[_local3][(_local1 - _local2) - 1];
_local2++;
}
_local3++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local1++;
}
xx[0] = xx[0] + 3;
xx[1] = xx[1] + 3;
xx[2] = xx[2] + 3;
xx[3] = xx[3] + 3;
_root.attachMovie("piece", "currentpiece" + piececount, piececount * 4);
this["currentpiece" + piececount]._x = xx[0] * unitsize;
this["currentpiece" + piececount]._y = yy[0] * unitsize;
this["currentpiece" + piececount]._width = unitsize;
this["currentpiece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current2piece" + piececount, (piececount * 4) + 1);
this["current2piece" + piececount]._x = xx[1] * unitsize;
this["current2piece" + piececount]._y = yy[1] * unitsize;
this["current2piece" + piececount]._width = unitsize;
this["current2piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current3piece" + piececount, (piececount * 4) + 2);
this["current3piece" + piececount]._x = xx[2] * unitsize;
this["current3piece" + piececount]._y = yy[2] * unitsize;
this["current3piece" + piececount]._width = unitsize;
this["current3piece" + piececount]._height = unitsize;
_root.attachMovie("piece", "current4piece" + piececount, (piececount * 4) + 3);
this["current4piece" + piececount]._x = xx[3] * unitsize;
this["current4piece" + piececount]._y = yy[3] * unitsize;
this["current4piece" + piececount]._width = unitsize;
this["current4piece" + piececount]._height = unitsize;
currentpiece = _root["currentpiece" + piececount];
currentpiece.gotoAndStop(frame);
current2piece = _root["current2piece" + piececount];
current2piece.gotoAndStop(frame);
current3piece = _root["current3piece" + piececount];
current3piece.gotoAndStop(frame);
current4piece = _root["current4piece" + piececount];
current4piece.gotoAndStop(frame);
moviecliplist.push(currentpiece);
moviecliplist.push(current2piece);
moviecliplist.push(current3piece);
moviecliplist.push(current4piece);
}
};
newpiece = function () {
rotatedcount = 0;
piececount++;
var _local2 = Math.floor(Math.random() * 7);
frame = _local2 + 1;
piecetype = _local2;
if (_local2 == 0) {
var _local1 = 0;
while (_local1 < 4) {
xx[_local1] = _local1;
yy[_local1] = 0;
_local1++;
}
} else if (_local2 == 1) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 2;
yy[2] = 0;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 2) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 0;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 3) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 0;
yy[1] = 1;
xx[2] = 1;
yy[2] = 1;
xx[3] = 1;
yy[3] = 0;
} else if (_local2 == 4) {
xx[0] = 0;
yy[0] = 1;
xx[1] = 1;
yy[1] = 1;
xx[2] = 1;
yy[2] = 0;
xx[3] = 2;
yy[3] = 0;
} else if (_local2 == 5) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 1;
} else if (_local2 == 6) {
xx[0] = 0;
yy[0] = 0;
xx[1] = 1;
yy[1] = 0;
xx[2] = 1;
yy[2] = 1;
xx[3] = 2;
yy[3] = 0;
}
newpieceattach();
};
_root.onEnterFrame = function () {
framecount++;
current4piece._y = (yy[3] - 1) * unitsize;
current3piece._y = (yy[2] - 1) * unitsize;
current2piece._y = (yy[1] - 1) * unitsize;
currentpiece._y = (yy[0] - 1) * unitsize;
if (Key.isDown(40) && (!paused)) {
score = score + level;
speed = 1;
} else {
speed = levelspeed;
}
if ((framecount % speed) == 0) {
if (!paused) {
if ((((unitmap[xx[0]][yy[0] + 1] == undefined) && (unitmap[xx[1]][yy[1] + 1] == undefined)) && (unitmap[xx[2]][yy[2] + 1] == undefined)) && (unitmap[xx[3]][yy[3] + 1] == undefined)) {
current4piece._y = yy[3] * unitsize;
current3piece._y = yy[2] * unitsize;
current2piece._y = yy[1] * unitsize;
currentpiece._y = yy[0] * unitsize;
var _local1 = 0;
while (_local1 < 4) {
yy[_local1]++;
_local1++;
}
} else {
unitmap[xx[0]][yy[0]] = currentpiece;
unitmap[xx[1]][yy[1]] = current2piece;
unitmap[xx[2]][yy[2]] = current3piece;
unitmap[xx[3]][yy[3]] = current4piece;
newpiece();
framecount = 7;
}
}
}
};
stop();
Frame 21
stop();
stopAllSounds();
Symbol 8 MovieClip [piece] Frame 1
stop();
Symbol 19 MovieClip Frame 1
_root.stop();
PercentLoaded = (_root.getBytesLoaded() / _root.getBytesTotal()) * 100;
if (PercentLoaded != 100) {
bar._xscale = PercentLoaded;
} else {
gotoAndPlay ("loaded");
}
Symbol 19 MovieClip Frame 2
gotoAndPlay (1);
Symbol 19 MovieClip Frame 40
_root.play();
Symbol 51 Button
on (release) {
gotoAndPlay (3);
}
Symbol 64 Button
on (release) {
gotoAndPlay (5);
}
Symbol 68 Button
on (release) {
gotoAndPlay (7);
}
Symbol 72 Button
on (release) {
gotoAndPlay (6);
}
Symbol 76 Button
on (release) {
gotoAndPlay (8);
}
Symbol 80 Button
on (release) {
gotoAndPlay (2);
}
Symbol 85 Button
on (release) {
gotoAndPlay (21);
}
Symbol 97 Button
on (release) {
gotoAndPlay (9);
}
Symbol 101 Button
on (release) {
gotoAndPlay (10);
}
Symbol 105 Button
on (release) {
gotoAndPlay (11);
}
Symbol 109 Button
on (release) {
gotoAndPlay (2);
}
Symbol 113 Button
on (release) {
gotoAndPlay (4);
}
Symbol 114 Button
on (release) {
gotoAndPlay (12);
}
Symbol 115 Button
on (release) {
gotoAndPlay (13);
}
Symbol 116 Button
on (release) {
gotoAndPlay (14);
}
Symbol 117 Button
on (release) {
gotoAndPlay (15);
}
Symbol 118 Button
on (release) {
gotoAndPlay (16);
}
Symbol 119 Button
on (release) {
gotoAndPlay (17);
}
Symbol 120 Button
on (release) {
gotoAndPlay (3);
}
Symbol 121 Button
on (release) {
gotoAndPlay (18);
}
Symbol 122 Button
on (release) {
gotoAndPlay (19);
}
Symbol 123 Button
on (release) {
gotoAndPlay (20);
}
Symbol 135 MovieClip Frame 1
stop();
Symbol 135 MovieClip Frame 2
stop();
Symbol 229 Button
on (release) {
gotoAndPlay (2);
}
Symbol 233 Button
on (release) {
gotoAndPlay (4);
}