📄 俄罗斯.txt
字号:
_root["w" (_root.iii 3)]._y = _root.currentmove._y;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case -90 :
_root.attachMovie("square", "w" _root.iii, 100 _root.iii);
_root["w" _root.iii]._x = _root.currentmove._x-10;
_root["w" _root.iii]._y = _root.currentmove._y;
x1 = (xx-40)/10-1;
y1 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 1), 100 _root.iii 1);
_root["w" (_root.iii 1)]._x = _root.currentmove._x;
_root["w" (_root.iii 1)]._y = _root.currentmove._y;
x2 = (xx-40)/10;
y2 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 2), 100 _root.iii 2);
_root["w" (_root.iii 2)]._x = _root.currentmove._x;
_root["w" (_root.iii 2)]._y = _root.currentmove._y-10;
x3 = (xx-40)/10;
y3 = (330-yy)/10 1;
_root.attachMovie("square", "w" (_root.iii 3), 100 _root.iii 3);
_root["w" (_root.iii 3)]._x = _root.currentmove._x;
_root["w" (_root.iii 3)]._y = _root.currentmove._y-20;
x4 = (xx-40)/10;
y4 = (330-yy)/10 2;
break;
}
break;
case 7 :
switch (rot) {
case 0 :
_root.attachMovie("square", "w" _root.iii, 100 _root.iii);
_root["w" _root.iii]._x = _root.currentmove._x-20;
_root["w" _root.iii]._y = _root.currentmove._y;
x1 = (xx-40)/10-2;
y1 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 1), 100 _root.iii 1);
_root["w" (_root.iii 1)]._x = _root.currentmove._x-10;
_root["w" (_root.iii 1)]._y = _root.currentmove._y;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 2), 100 _root.iii 2);
_root["w" (_root.iii 2)]._x = _root.currentmove._x;
_root["w" (_root.iii 2)]._y = _root.currentmove._y;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 3), 100 _root.iii 3);
_root["w" (_root.iii 3)]._x = _root.currentmove._x;
_root["w" (_root.iii 3)]._y = _root.currentmove._y-10;
x4 = (xx-40)/10;
y4 = (330-yy)/10 1;
break;
case 90 :
_root.attachMovie("square", "w" _root.iii, 100 _root.iii);
_root["w" _root.iii]._x = _root.currentmove._x-10;
_root["w" _root.iii]._y = _root.currentmove._y-20;
x1 = (xx-40)/10-1;
y1 = (330-yy)/10 2;
_root.attachMovie("square", "w" (_root.iii 1), 100 _root.iii 1);
_root["w" (_root.iii 1)]._x = _root.currentmove._x-10;
_root["w" (_root.iii 1)]._y = _root.currentmove._y-10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10 1;
_root.attachMovie("square", "w" (_root.iii 2), 100 _root.iii 2);
_root["w" (_root.iii 2)]._x = _root.currentmove._x-10;
_root["w" (_root.iii 2)]._y = _root.currentmove._y;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 3), 100 _root.iii 3);
_root["w" (_root.iii 3)]._x = _root.currentmove._x;
_root["w" (_root.iii 3)]._y = _root.currentmove._y;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case 180 :
_root.attachMovie("square", "w" _root.iii, 100 _root.iii);
_root["w" _root.iii]._x = _root.currentmove._x-10;
_root["w" _root.iii]._y = _root.currentmove._y;
x1 = (xx-40)/10-1;
y1 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 1), 100 _root.iii 1);
_root["w" (_root.iii 1)]._x = _root.currentmove._x-10;
_root["w" (_root.iii 1)]._y = _root.currentmove._y-10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10 1;
_root.attachMovie("square", "w" (_root.iii 2), 100 _root.iii 2);
_root["w" (_root.iii 2)]._x = _root.currentmove._x;
_root["w" (_root.iii 2)]._y = _root.currentmove._y-10;
x3 = (xx-40)/10;
y3 = (330-yy)/10 1;
_root.attachMovie("square", "w" (_root.iii 3), 100 _root.iii 3);
_root["w" (_root.iii 3)]._x = _root.currentmove._x 10;
_root["w" (_root.iii 3)]._y = _root.currentmove._y-10;
x4 = (xx-40)/10 1;
y4 = (330-yy)/10 1;
break;
case -90 :
_root.attachMovie("square", "w" _root.iii, 100 _root.iii);
_root["w" _root.iii]._x = _root.currentmove._x-10;
_root["w" _root.iii]._y = _root.currentmove._y-10;
x1 = (xx-40)/10-1;
y1 = (330-yy)/10 1;
_root.attachMovie("square", "w" (_root.iii 1), 100 _root.iii 1);
_root["w" (_root.iii 1)]._x = _root.currentmove._x;
_root["w" (_root.iii 1)]._y = _root.currentmove._y-10;
x2 = (xx-40)/10;
y2 = (330-yy)/10 1;
_root.attachMovie("square", "w" (_root.iii 2), 100 _root.iii 2);
_root["w" (_root.iii 2)]._x = _root.currentmove._x;
_root["w" (_root.iii 2)]._y = _root.currentmove._y;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
_root.attachMovie("square", "w" (_root.iii 3), 100 _root.iii 3);
_root["w" (_root.iii 3)]._x = _root.currentmove._x;
_root["w" (_root.iii 3)]._y = _root.currentmove._y 10;
x4 = (xx-40)/10;
y4 = (330-yy)/10-1;
break;
}
break;
}
_root.box[y1][x1] = 1;
_root.box[y2][x2] = 1;
_root.box[y3][x3] = 1;
_root.box[y4][x4] = 1;
_root.iii = 4;
judgescore();
}
function judgescore() {
if (_root.box[29][6] == 1 || _root.box[29][7] == 1 || _root.box[29][8] == 1 || _root.box[29][9] == 1 || _root.box[29][10] == 1) {
nextFrame();
}
_root.fill1 = -1;
_root.fill2 = -1;
_root.fill3 = -1;
_root.fill4 = -1;
for (var m = 0; m<=29; m ) {
_root.gain = true;
for (var n = 0; n<=15; n ) {
if (_root.box[m][n] == 0) {
_root.gain = false;
}
}
if (_root.gain == true) {
_root.fill1 = m;
}
}
if (_root.fill1 != -1) {
_root.top.score = Number(_root.top.score) 100;
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y == 330-_root.fill1*10) {
_root["w" z].removeMovieClip();
}
}
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y<330-_root.fill1*10) {
_root["w" z]._y = 10;
}
}
for (var c = _root.fill1; c<=28; c ) {
for (var d = 0; d<=15; d ) {
_root.box[c][d] = _root.box[c 1][d];
}
}
for (var m = 0; m<=29; m ) {
_root.gain = true;
for (var n = 0; n<=15; n ) {
if (_root.box[m][n] == 0) {
_root.gain = false;
}
}
if (_root.gain == true) {
_root.fill2 = m;
}
}
if (_root.fill2 != -1) {
_root.top.score = Number(_root.top.score) 200;
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y == 330-_root.fill2*10) {
_root["w" z].removeMovieClip();
}
}
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y<330-_root.fill2*10) {
_root["w" z]._y = 10;
}
}
for (var c = _root.fill2; c<=28; c ) {
for (var d = 0; d<=15; d ) {
_root.box[c][d] = _root.box[c 1][d];
}
}
for (var m = 0; m<=29; m ) {
_root.gain = true;
for (var n = 0; n<=15; n ) {
if (_root.box[m][n] == 0) {
_root.gain = false;
}
}
if (_root.gain == true) {
_root.fill3 = m;
}
}
if (_root.fill3 != -1) {
_root.top.score = Number(_root.top.score) 300;
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y == 330-_root.fill3*10) {
_root["w" z].removeMovieClip();
}
}
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y<330-_root.fill3*10) {
_root["w" z]._y = 10;
}
}
for (var c = _root.fill3; c<=28; c ) {
for (var d = 0; d<=15; d ) {
_root.box[c][d] = _root.box[c 1][d];
}
}
for (var m = 0; m<=29; m ) {
_root.gain = true;
for (var n = 0; n<=15; n ) {
if (_root.box[m][n] == 0) {
_root.gain = false;
}
}
if (_root.gain == true) {
_root.fill4 = m;
}
}
if (_root.fill4 != -1) {
_root.top.score = Number(_root.top.score) 400;
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y == 330-_root.fill4*10) {
_root["w" z].removeMovieClip();
}
}
for (var z = 0; z<=_root.iii; z ) {
if (_root["w" z]._y<330-_root.fill4*10) {
_root["w" z]._y = 10;
}
}
for (var c = _root.fill4; c<=28; c ) {
for (var d = 0; d<=15; d ) {
_root.box[c][d] = _root.box[c 1][d];
}
}
}
}
}
}
_root.fill1 = -1;
_root.fill2 = -1;
_root.fill3 = -1;
_root.fill4 = -1;
}
这里,主要为游戏定义几个函数,它们共同实现了方块游戏的基本功能。其中,函数hitothers用于判断下落的方块是否与已经落下的方块接触,如果接触,就需要停止下落。函数attachsquares用在当方块停止下落时将库中的“square”元件附加到适当的位置。函数judgescore判断方块停止下落并附加小方块后是否得分,它是通过分析与方块对应位置的数组元素的值完成判断的。
(2)选中主时间轴的第2帧,在其“动作”面板中添加如下代码:
stop();
_root.restart.removeMovieClip();
_root.currentshape = 0;
_root.iii = 1;
_root.fall = true;
_root.wait = 0;
_root.v = 6-Number(_root.top.v);
_root.hit = false;
_root.top.duplicateMovieClip("top", 99999);
_root.top.score = 0;
_root.ran1 = random(7) 1;
_root.box = new Array();
for (var i = 0; i<=29; i ) {
_root.box[i] = new Array();
for (var j = 0; j<=15; j ) {
_root.box[i][j] = 0;
}
}
Key.addListener(_root);
_root.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
_root.currentmove._x -= 10;
hitothers(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
if (_root.currentmove.hitTest(_root.left) || _root.hit == true) {
_root.currentmove._x = 10;
}
} else if (Key.getCode() == Key.RIGHT) {
_root.currentmove._x = 10;
hitothers(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
if (_root.currentmove.hitTest(_root.right) || _root.hit == true) {
_root.currentmove._x -= 10;
}
} else if (Key.getCode() == Key.DOWN) {
_root.fall = false;
_root.currentmove._y = 10;
hitothers(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
if (_root.currentmove.hitTest(_root.base) || _root.hit == true) {
_root.currentmove._y -= 10;
attachsquares(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
removeMovieClip(_root.currentmove);
_root.currentshape = 0;
}
_root.fall = true;
} else if (Key.getCode() == Key.UP) {
_root.currentmove._rotation = 90;
hitothers(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
if (_root.currentmove.hitTest(_root.right) || _root.currentmove.hitTest(_root.left) || _root.hit == true) {
_root.currentmove._rotation -= 90;
}
}
};
_root.onEnterFrame = function() {
if (_root.currentshape == 0) {
_root.ran = _root.ran1;
_root.attachMovie("shape" _root.ran, "currentmove", 100);
_root.currentmove._x = 120;
_root.currentmove._y = 40;
_root.currentshape = _root.ran;
_root.currentmove.onEnterFrame = function() {
if (_root.fall == true) {
if (_root.wait == _root.v) {
this._y = 10;
_root.wait = 0;
} else {
_root.wait ;
}
}
};
_root.ran1 = random(7) 1;
_root.attachMovie("shape" _root.ran1, "nextmove", 100001);
_root.nextmove._x = 200;
_root.nextmove._y = 20;
}
hitothers(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
if ((_root.hit == true || _root.currentmove.hitTest(_root.base)) && (_root.fall == true)) {
_root.currentmove._y -= 10;
attachsquares(_root.currentmove._x, _root.currentmove._y, _root.ran, _root.currentmove._rotation);
removeMovieClip(_root.currentmove);
_root.currentshape = 0;
}
};
这一帧实现游戏的运行,通过定义事件处理函数分析键盘动作,以实现用方向键对方块进行控制。在方块下落过程,适时地调用第1帧中定义的函数,保证了游戏的严密性。
(3)双击第2帧中的“界面”元件,进入其元件层级,选中“加速”按钮,在其“动作”面板中添加如下代码:
on (release) {
if (_root.top.v<6) {
_root.top.v = Number(_root.top.v) 1;
}
_root.wait = 0;
_root.v = 6-Number(_root.top.v);
}
单击该按钮,方块下落速度增大,但最大不超过6。
(4)选中“减速”按钮,在其“动作”面板中添加如下代码:
on (release) {
if (_root.top.v>1) {
_root.top.v = Number(_root.top.v)-1;
}
_root.wait = 0;
_root.v = 6-Number(_root.top.v);
}
单击该按钮,方块下落速度减小,但最小不低于1。
(5)选中“跳出”按钮,在其“动作”面板中添加如下代码:
on (release) {
removeMovieClip(_root.currentmove);
_root.nextFrame();
}
单击该按钮,删除正在下落的方块,并跳转到游戏的第3帧,游戏结束。
(6)选中主时间轴中的第3帧,在其“动作”面板中添加如下代码:
stop();
这一帧是游戏的结束画面,当方块到达顶层或单击“跳出”按钮时,游戏转到这一帧,显示重新开始按钮。
(7)选中第3帧中的影片剪辑元件“重新开始-剪辑”,打开其“动作”面板,在其中添加如下代码:
onClipEvent (enterFrame) {
this.duplicateMovieClip("restart", 100000);
}
上面的语句使元件“重新开始-剪辑”的实例置于最顶层。
(8)双击第3帧中的元件“重新开始-剪辑”进入其元件层级,选中其中的按钮元件“重新开始-按钮”,打开其“动作”面板,在其中添加如下代码:
on (release) {
for (var del = 0; del<=_root.iii; del ) {
_root["w" del].removeMovieClip();
}
for (var p = 0; p<=39; p ) {
for (var q = 0; q<=25; q ) {
_root.box[p][q] = 0;
}
}
_root.gotoAndStop(2);
}
当单击该按钮时,清除场景中的所有方块,并复原对应于方块位置的数组,跳转到第2帧,游戏重新开始。
(9)按【Ctrl Enter】键测试影片,游戏进入第2帧并停止,方块开始下落。在当前方块下落的同时,面板右上角同时出现下一个要下落的方块的提示。
(10)按方向键控制下落的方块。按【→】键方块右移,按【←】键方块左移,按【↑】键方块旋转,按【↓】键方块加速下落。
(11)游戏结束或单击“跳出”按钮时跳到第3帧。此时可以单击“重新开始”按钮重新开始游戏。
由于方块形状多,每个方块具有4个旋转角度,因此本例最容易出现问题的地方就在于不同形状方块的计算上,需要多加注意。
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -