Frame 1
stop();
Frame 2
stopAllSounds();
stop();
stop();
Frame 3
var unitsize = 20;
var unitheight = 20;
var unitwidth = 10;
var piececount = 0;
var piecetype;
var oldlines = 0;
var speed = 10;
var frame = 1;
var level = 1;
var realpaused = false;
var levelspeed = 8;
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 _local3 = 0;
while (_local3 <= unitheight) {
if ((((((((((unitmap[0][_local3] != undefined) && (unitmap[1][_local3] != undefined)) && (unitmap[2][_local3] != undefined)) && (unitmap[3][_local3] != undefined)) && (unitmap[4][_local3] != undefined)) && (unitmap[5][_local3] != undefined)) && (unitmap[6][_local3] != undefined)) && (unitmap[7][_local3] != undefined)) && (unitmap[8][_local3] != undefined)) && (unitmap[9][_local3] != undefined)) {
var _local5 = 0;
while (_local5 < unitwidth) {
removeMovieClip(unitmap[_local5][_local3]);
var _local4 = 0;
while (_local4 < unitheight) {
unitmap[_local5][_local3 - _local4]._y = unitmap[_local5][_local3 - _local4]._y + unitsize;
unitmap[_local5][_local3 - _local4] = unitmap[_local5][(_local3 - _local4) - 1];
_local4++;
}
_local5++;
}
oldlines++;
score = score + (((level * oldlines) * oldlines) * 100);
lines++;
if (((lines % 10) == 0) && (levelspeed > 1)) {
levelspeed--;
level++;
}
}
_local3++;
}
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 4
stop();
stop();
Symbol 8 MovieClip [piece] Frame 1
stop();
Symbol 17 Button
on (release) {
getURL ("http://www.newgrounds.com", "blank");
}
Symbol 22 Button
on (release) {
_root.play();
}
Symbol 23 MovieClip Frame 1
_root.stop();
PercentLoaded = (_root.getBytesLoaded() / _root.getBytesTotal()) * 100;
if (PercentLoaded != 100) {
bar._xscale = PercentLoaded;
} else {
gotoAndStop ("loaded");
}
Symbol 23 MovieClip Frame 2
gotoAndPlay (1);
Symbol 37 Button
on (release) {
gotoAndPlay (2);
}
Symbol 70 Button
on (release) {
gotoAndPlay (1);
}
Symbol 71 MovieClip Frame 1
stop();
Symbol 75 Button
on (release) {
gotoAndPlay (6);
}
Symbol 76 Button
on (release) {
gotoAndPlay (4);
}