Frame 1
stop();
Stage.showMenu = false;
startLevel = 1;
this.onEnterFrame = function () {
sofar = this.getBytesLoaded();
total = this.getBytesTotal();
if (sofar == total) {
delete this.onEnterFrame;
nextFrame();
}
};
Frame 2
String.prototype.addCommas = function () {
var len = this.length;
var str = "";
var i = 0;
while (i <= len) {
str = this.charAt(len - i) + str;
if ((((i % 3) == 0) && (i > 0)) && (i < len)) {
str = "," + str;
}
i++;
}
return(str);
};
so = SharedObject.getLocal("neaveTetris");
if (!playerName.length) {
playerName = so.data.playerName;
}
score = 0;
level = startLevel;
this.onKeyDown = function () {
if (Key.getCode() == 81) {
getURL ("javascript:window.close();");
}
};
Key.addListener(this);
Frame 3
function checkBtns() {
if (startLevel < 2) {
DnBtn._alpha = 50;
DnBtn.enabled = false;
} else if (startLevel > 9) {
UpBtn._alpha = 50;
UpBtn.enabled = false;
} else {
UpBtn._alpha = (DnBtn._alpha = 100);
UpBtn.enabled = (DnBtn.enabled = true);
}
}
stop();
checkBtns();
Frame 4
function startFall() {
timeout = setInterval(down, speed);
}
function stopFall() {
clearInterval(timeout);
}
function drawBlock(num, blockPos) {
B[blockPos].gotoAndStop(num + 1);
}
function drawNextBlock(num, blockPos) {
N[blockPos].gotoAndStop(num + 1);
}
function drawThisShape() {
if (moved) {
var i = 0;
while (i < 4) {
drawBlock(0, block[i]);
i++;
}
} else {
moved = true;
}
var i = 0;
while (i < 4) {
blockPos = shape[((thisShape * 16) + (rotation * 4)) + i];
block[i] = ((((blockPos >> 2) * 6) + blockPos) + xPos) + yPos;
drawBlock(thisShape + 1, block[i]);
i++;
}
}
function drawNextShape() {
nextShape = int(Math.random() * 7);
var i = 0;
while (i < 11) {
drawNextBlock(0, i);
i++;
}
var i = 0;
while (i < 4) {
drawNextBlock(nextShape + 1, shape[(nextShape * 16) + i]);
i++;
}
}
function collision(x, y, rot) {
var i = 0;
while (i < 4) {
blockPos = shape[((thisShape * 16) + (rot * 4)) + i];
if (flag[((((blockPos >> 2) * 6) + blockPos) + x) + y] != 0) {
return(true);
}
i++;
}
return(false);
}
function left() {
var i = 0;
while (i < 4) {
var x = (block[i] - yPos);
while (x >= 0) {
if (x == 0) {
return(undefined);
}
x = x - 10;
}
i++;
}
if (!collision(xPos - 1, yPos, rotation)) {
xPos--;
drawThisShape();
}
}
function right() {
var i = 0;
while (i < 4) {
var x = (block[i] - yPos);
while (x >= 0) {
if (x == 9) {
return(undefined);
}
x = x - 10;
}
i++;
}
if (!collision(xPos + 1, yPos, rotation)) {
xPos++;
drawThisShape();
}
}
function rotate(clockwise) {
testRot = rotation;
if (clockwise) {
testRot++;
} else {
testRot--;
}
if (testRot == 4) {
testRot = 0;
} else if (testRot == -1) {
testRot = 3;
}
var i = 0;
while (i < 4) {
blockPos = shape[((thisShape * 16) + (testRot * 4)) + i];
var x = ((((blockPos >> 2) * 6) + blockPos) + xPos);
while (x >= -1) {
if (((x == -1) && (xPos < 0)) || ((x == 0) && (xPos > 6))) {
return(undefined);
}
x = x - 10;
}
i++;
}
if ((((((blockPos >> 2) * 6) + blockPos) + xPos) + yPos) > 179) {
return(undefined);
}
if (!collision(xPos, yPos, testRot)) {
rotation = testRot;
drawThisShape();
Snd.gotoAndPlay("popHi");
}
}
function down() {
if (gameOver || (simult)) {
return(undefined);
}
score++;
if (((block[3] - xPos) < 170) && (!collision(xPos, yPos + 10, rotation))) {
yPos = yPos + 10;
drawThisShape();
} else {
var i = 0;
while (i < 4) {
flag[block[i]] = thisShape + 1;
i++;
}
simult = 0;
var y = 0;
while (y < 180) {
var x = 0;
while (x < 10) {
if (flag[x + y] == 0) {
break;
}
if (x == 9) {
stopFall();
var i = 0;
while (i < 10) {
B[i + y].Bang.y = y;
B[i + y].Bang.play();
i++;
}
simult++;
lines++;
}
x++;
}
y = y + 10;
}
if (simult) {
Snd.gotoAndPlay("win");
switch (simult) {
case 1 :
score = score + (level * 40);
break;
case 2 :
score = score + (level * 100);
break;
case 3 :
score = score + (level * 300);
break;
case 4 :
score = score + (level * 1200);
}
}
scoreTxt = String(score).addCommas();
if (collision(xPos, yPos, rotation) && (yPos == -10)) {
gameOver = true;
stopFall();
Snd.gotoAndPlay("end");
Quitter.gotoAndStop(2);
Quitter._visible = true;
} else {
level = int(lines / 10) + startLevel;
speed = ((level < 10) ? (600 - (level * 50)) : 100);
xPos = 3;
yPos = -10;
rotation = 0;
moved = false;
thisShape = nextShape;
if (!simult) {
drawNextShape();
drawThisShape();
Snd.gotoAndPlay("popLo");
}
}
}
updateAfterEvent();
}
function pause() {
if (gameOver || (Quitter._visible)) {
return(undefined);
}
Snd.gotoAndPlay("popMed");
B._visible = !((Unpause._visible = (paused = !paused)));
if (paused) {
stopFall();
} else {
startFall();
}
}
function quit() {
if (gameOver) {
return(undefined);
}
Snd.gotoAndPlay("popMed");
stopFall();
B._visible = (Unpause._visible = false);
Quitter._visible = (paused = true);
}
this.onKeyDown = function () {
if (gameOver || (simult)) {
return(undefined);
}
var keyCode = Key.getCode();
switch (keyCode) {
case 80 :
pause();
break;
case 81 :
quit();
}
if (!paused) {
switch (keyCode) {
case Key.LEFT :
left();
break;
case Key.RIGHT :
right();
break;
case Key.DOWN :
this.onEnterFrame = down;
break;
case Key.UP :
case 88 :
rotate(true);
break;
case 90 :
rotate(false);
}
}
updateAfterEvent();
};
this.onKeyUp = function () {
delete this.onEnterFrame;
};
Key.addListener(this);
gameOver = true;
paused = (moved = false);
score = (scoreTxt = (lines = (thisShape = (nextShape = (rotation = 0)))));
level = startLevel;
speed = ((level < 10) ? (600 - (level * 50)) : 100);
xPos = 3;
yPos = -10;
shape = new Array(5, 6, 9, 10, 5, 6, 9, 10, 5, 6, 9, 10, 5, 6, 9, 10, 4, 5, 6, 9, 1, 4, 5, 9, 1, 4, 5, 6, 1, 5, 6, 9, 4, 5, 9, 10, 2, 5, 6, 9, 4, 5, 9, 10, 2, 5, 6, 9, 5, 6, 8, 9, 1, 5, 6, 10, 5, 6, 8, 9, 1, 5, 6, 10, 4, 5, 6, 8, 0, 1, 5, 9, 2, 4, 5, 6, 1, 5, 9, 10, 4, 5, 6, 10, 1, 5, 8, 9, 0, 4, 5, 6, 1, 2, 5, 9, 4, 5, 6, 7, 1, 5, 9, 13, 4, 5, 6, 7, 1, 5, 9, 13);
block = new Array(0, 0, 0, 0);
flag = new Array();
var i = 18;
while (i >= 0) {
var j = 0;
while (j < 10) {
var k = ((i * 10) + j);
B.attachMovie("Block", k, k, {_x:j * 20, _y:i * 20});
flag[k] = 0;
j++;
}
i--;
}
var i = 0;
while (i < 3) {
var j = 0;
while (j < 4) {
var k = ((i * 4) + j);
N.attachMovie("Block", k, k, {_x:j * 20, _y:i * 20});
j++;
}
i++;
}
Instance of Symbol 62 MovieClip "Quitter" in Frame 16
onClipEvent (load) {
_visible = false;
}
Instance of Symbol 65 MovieClip "Unpause" in Frame 16
onClipEvent (load) {
_visible = false;
}
Frame 24
stop();
drawNextShape();
thisShape = nextShape;
drawThisShape();
drawNextShape();
gameOver = false;
startFall();
Symbol 2 MovieClip Frame 1
stop();
Symbol 2 MovieClip Frame 7
x = Number(_parent._name) - y;
with (_root) {
var j = y;
while (j > 0) {
drawBlock((flag[x + j] = flag[(x + j) - 10]), x + j);
j = j - 10;
}
if (!x) {
simult--;
}
if (!simult) {
drawNextShape();
drawThisShape();
startFall();
}
}
Symbol 10 MovieClip [Block] Frame 1
stop();
Symbol 20 Button
on (press) {
Key.removeListener(this);
play();
}
Symbol 23 Button
on (release) {
getURL ("http://www.neave.com/games/", "_blank");
}
Symbol 26 MovieClip Frame 12
stop();
Symbol 30 Button
on (press) {
play();
}
Symbol 32 Button
on (press) {
startLevel++;
checkBtns();
}
Symbol 33 Button
on (press) {
startLevel--;
checkBtns();
}
Symbol 38 MovieClip Frame 1
stop();
Symbol 38 MovieClip Frame 3
stop();
Symbol 38 MovieClip Frame 5
stop();
Symbol 38 MovieClip Frame 7
stop();
Symbol 38 MovieClip Frame 9
stop();
Symbol 51 Button
on (press) {
quit();
}
Symbol 53 Button
on (press) {
pause();
}
Symbol 56 Button
on (press, keyPress "y") {
tellTarget ("/") {
stopFall();
gotoAndStop (2);
};
}
Symbol 58 Button
on (press, keyPress "n") {
_visible = false;
_root.pause();
}
Symbol 60 Button
on (press) {
tellTarget ("/") {
stopFall();
gotoAndStop (2);
};
}
Symbol 62 MovieClip Frame 1
stop();
Symbol 62 MovieClip Frame 2
_root.PauseBtn._visible = (_root.QuitBtn._visible = false);
Selection.setFocus(NameTxt);
Selection.setSelection(NameTxt.length, NameTxt.length);
NameTxt.restrict = "a-z 0-9.:\\-";
Instance of Symbol 63 MovieClip "Hit" in Symbol 65 MovieClip Frame 1
on (press) {
_root.pause();
}