您的位置:首页 > 其它

俄罗斯方块(flash游戏制作)

2007-06-04 23:08 387 查看
演示:http://www.7880.com/Upload/2004_Pack/20046159502441.swf

俄罗斯方块是一款经典的小游戏,本例利用ActionScript将其在Flash中实现出来。游戏中共有7种形状的方块,它们出现并下落的顺序是随机 的,与传统的俄罗斯方块一样,这里也有下一个要下落的方块的提示。当前方块停止下落时,判断得分,继续出现下一个方块。此外,还可以通过单击按钮调节方块 下落速度。
制作方法分析
制作方块游戏要求的方面比较多,下面对重要的部分予以介绍。
1. 随机产生方块
要随机产生方块自然要用到随机数,这里在每种形状方块的影片剪辑的链接标识符中加入代表方块形状的序号,根据产生的随机数决定产生哪种形状的方块。由于既要产生当前方块,又要产生下一个要下落的方块,因此需要使用两个变量来存放随机数。
2. 对方块进行控制
方 块在下落过程中可以进行左移、右移、加速下落和旋转,这些都可以通过键盘进行控制。由于方块在EnterFrame事件中下落,会造成速度快得无法接受的 结果,因此在EnterFrame事件中使用一个变量进行计数,当计数变量达到某一值时才令方块下落。这样出使得可以通过调整计数变量的最大值来控制方块 的下落速度。
3. 方块停止检测
当方块下落(或左移、右移)到边界或其他方块位置,不能再移动时,方块停止运动。这就需要对方块应该在何 处停止进行判断。由于在一行填满时需要清除该行方块,因此在方块停止下落时应该使用独立的方块单元代替当前方块。为了更便于对一行是否填满进行检测,定义 了一个二维数组,数组的每个元素代表游戏界面中一个特定的位置,因此只需要判断对应于某位置的数组元素的值就可以知道该位置是否有方块存在。无论是在方块 停止检测还是在是否得分的计算上,这个数组都发挥了巨大的作用。
4. 得分计算
和传统的俄罗斯方块一样,如果一次清除的行数越多,得分就 应该越高。这个比较容易,只需在已经得分的情况下再进行一次得分判断,以此类推,每次得分判断成功都可以得到更高的分数。在得分的情况下需要做两件事情, 一是清除得分行的方块,二是将该行以上的方块都向下移动一行的距离。当然,在清除和移动方块位置的同时需要相应地改变数组元素的值。
制作过程
下面首先制作游戏中需要用到的方块。
(1)按【Ctrl+F8】键创建一个名为“方块”的影片剪辑元件并进入编辑。
(2)使用文本工具绘制一个10×10的矩形,其笔触颜色为#333333,填充颜色为#999999,将其左上角对齐元件中心。
(3)创建影片剪辑元件“形状1”~“形状7”,分别使用与步骤(2)中相同的笔触颜色和填充颜色绘制不同形状的方块,其中构成这些方块的小方块的大小都为10×10。
(4)在“库”面板的元件“方块”上单击鼠标右键,在弹出的快捷菜单中选择“链接”命令,打开“链接属性”对话框,为其添加链接,并将链接标识符设置为“square”。
(5)单击 按钮完成设置。
(6)在“库”面板的元件“形状1”上单击鼠标右键,在弹出的快捷菜单中选择“链接”命令,在打开的“链接属性”对话框中为其添加链接,将其链接标识符设置为“shape1”。
(7)按照与步骤(6)相似的方法将元件“形状1”~“形状7”的链接标识符设置为“shape1”~“shape7”。
1.2.2 制作按钮
该游戏用到的按钮主要有:控制方块下落速度的按钮,跳出游戏的按钮和重新开始游戏的按钮。
(1)按【Ctrl+F8】键创建一个名为“加速”的按钮元件并进入编辑。
(2)在按钮的“弹起”帧绘制一个黄色三角形,然后在“指针经过”帧插入一个关键帧,将三角形的颜色改成红色。
(3)创建一个名为“减速”的按钮元件并进入编辑。
(4)在按钮的“弹起”帧和“指针经过”帧绘制图形。
(5)创建一个名为“跳出”的按钮元件并进入编辑。
(6)在元件“跳出”的“弹起”、“指针经过”和“点击”帧插入关键帧,并绘制图形。
(7)创建一个名为“重新开始-按钮”的按钮元件,设计其“弹起”、“指针经过”和“点击”帧。
(8)创建一个名为“重新开始-剪辑”的影片剪辑元件,将按钮元件“重新开始-按钮”拖放到其元件中心。
1.2.3 设计界面
下面为方块游戏设计界面。
(1)创建一个影片剪辑元件“水平边界”,在其中绘制一条长度为240px的水平直线,将其对齐元件中心。
(2)创建一个影片剪辑元件“竖直边界”,在其中绘制一条长度为400px的竖直直线,将其对齐元件中心。
(3)创建一个影片剪辑元件“界面”,使用矩形工具绘制一个240×400的渐变色矩形。
(4)使用矩形工具绘制一个160×300的白色矩形,将其放置到渐变色矩形中。
(5)选中白色矩形,按【Delete】键将其删除,使渐变色矩形呈挖空状态。
(6)新建一个图层,在其中添加制作好的按钮。
(7)再添加两个动态文本框。
(8)将显示为“4”的动态文本变量设置为“v”。
(9)将显示为“00000”的动态文本变量设置为“score”。
(10)回到主场景,将背景大小设置为240×400,背景颜色设置为#CCCCCC。
(11)在第2帧插入空白关键帧,将元件“水平边界”拖放到场景中,将其实例命名为“base”。
(12)将元件“竖直边界”拖出两个到场景中,将左边的实例命名为“left”,将右边的实例命名为“right”。其中,实例“left”的x坐标为35,实例“right”的x坐标为205。
(13)将元件“界面”拖放到第2帧的场景中,在“属性”面板中将其实例命名为“top”。
(14)在第3帧插入空白关键帧,将元件“重新开始-剪辑”拖放到场景中。
1.2.4 添加程序代码
该游戏用到的代码稍稍有些复杂,下面进行逐一添加。
(1)选中主时间轴中的第1帧,按【F9】键打开其“动作”面板,在其中添加如下代码:

function hitothers(xx, yy, num, rot) {
switch (num) {
case 1 :
switch (rot) {
case 0 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10+1;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case 90 :
x1 = (xx-40)/10;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10-1;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10;
break;
case 180 :
x1 = (xx-40)/10;
y1 = (330-yy)/10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
x3 = (xx-40)/10-2;
y3 = (330-yy)/10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10+1;
break;
case -90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+2;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10;
break;
}
break;
case 2 :
switch (rot) {
case 0 :
x1 = (xx-40)/10-2;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10+1;
break;
case 90 :
x1 = (xx-40)/10;
y1 = (330-yy)/10+2;
x2 = (xx-40)/10;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10;
y4 = (330-yy)/10-1;
break;
case 180 :
x1 = (xx-40)/10-2;
y1 = (330-yy)/10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10;
break;
case -90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+2;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10-1;
break;
}
break;
case 3 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10;
break;
case 4 :
switch (rot) {
case 0 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10;
break;
case 90 :
x1 = (xx-40)/10;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10;
y2 = (330-yy)/10;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10-1;
break;
case 180 :
x1 = (xx-40)/10-2;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case -90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10;
y4 = (330-yy)/10+2;
break;
}
break;
case 5 :
switch (rot) {
case 0 :
x1 = (xx-40)/10-2;
y1 = (330-yy)/10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10;
y4 = (330-yy)/10+1;
break;
case 90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+2;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case 180 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10;
x2 = (xx-40)/10;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10+1;
break;
case -90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10;
y4 = (330-yy)/10-1;
break;
}
break;
case 6 :
switch (rot) {
case 0 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10;
break;
case 90 :
x1 = (xx-40)/10;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10-1;
break;
case 180 :
x1 = (xx-40)/10-2;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case -90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10;
x2 = (xx-40)/10;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10;
y4 = (330-yy)/10+2;
break;
}
break;
case 7 :
switch (rot) {
case 0 :
x1 = (xx-40)/10-2;
y1 = (330-yy)/10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10;
y4 = (330-yy)/10+1;
break;
case 90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+2;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10-1;
y3 = (330-yy)/10;
x4 = (xx-40)/10;
y4 = (330-yy)/10;
break;
case 180 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10;
x2 = (xx-40)/10-1;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10+1;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10+1;
break;
case -90 :
x1 = (xx-40)/10-1;
y1 = (330-yy)/10+1;
x2 = (xx-40)/10;
y2 = (330-yy)/10+1;
x3 = (xx-40)/10;
y3 = (330-yy)/10;
x4 = (xx-40)/10;
y4 = (330-yy)/10-1;
break;
}
break;
}
if ((_root.box[y1][x1] == 1) || (_root.box[y2][x2] == 1) || (_root.box[y3][x3] == 1) || (_root.box[y4][x4] == 1)) {
_root.hit = true;
} else {
_root.hit = false;
}
}
function attachsquares(xx, yy, num, rot) {
switch (num) {
case 1 :
switch (rot) {
case 0 :
_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+10;
_root["w"+(_root.iii+2)]._y = _root.currentmove._y-10;
x3 = (xx-40)/10+1;
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;
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;
_root["w"+_root.iii]._y = _root.currentmove._y-10;
x1 = (xx-40)/10;
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;
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-10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10;
break;
case 180 :
_root.attachMovie("square", "w"+_root.iii, 100+_root.iii);
_root["w"+_root.iii]._x = _root.currentmove._x;
_root["w"+_root.iii]._y = _root.currentmove._y;
x1 = (xx-40)/10;
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-20;
_root["w"+(_root.iii+2)]._y = _root.currentmove._y;
x3 = (xx-40)/10-2;
y3 = (330-yy)/10;
_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-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;
_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;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10;
break;
}
break;
case 2 :
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-10;
x1 = (xx-40)/10-2;
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-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;
_root["w"+_root.iii]._y = _root.currentmove._y-20;
x1 = (xx-40)/10;
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;
_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;
case 180 :
_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+10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y;
x4 = (xx-40)/10+1;
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-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-10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y+10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10-1;
break;
}
break;
case 3 :
_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-10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10;
break;
case 4 :
switch (rot) {
case 0 :
_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+10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10;
break;
case 90 :
_root.attachMovie("square", "w"+_root.iii, 100+_root.iii);
_root["w"+_root.iii]._x = _root.currentmove._x;
_root["w"+_root.iii]._y = _root.currentmove._y-10;
x1 = (xx-40)/10;
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;
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-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-10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y+10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10-1;
break;
case 180 :
_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-10;
x1 = (xx-40)/10-2;
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-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 -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-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;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y-20;
x4 = (xx-40)/10;
y4 = (330-yy)/10+2;
break;
}
break;
case 5 :
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-10;
_root["w"+(_root.iii+2)]._y = _root.currentmove._y-10;
x3 = (xx-40)/10-1;
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-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;
_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;
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;
_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+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-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;
}
break;
case 6 :
switch (rot) {
case 0 :
_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-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+10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y;
x4 = (xx-40)/10+1;
y4 = (330-yy)/10;
break;
case 90 :
_root.attachMovie("square", "w"+_root.iii, 100+_root.iii);
_root["w"+_root.iii]._x = _root.currentmove._x;
_root["w"+_root.iii]._y = _root.currentmove._y-10;
x1 = (xx-40)/10;
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-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-10;
_root["w"+(_root.iii+3)]._y = _root.currentmove._y+10;
x4 = (xx-40)/10-1;
y4 = (330-yy)/10-1;
break;
case 180 :
_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-10;
x1 = (xx-40)/10-2;
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-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;
_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]
== 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]
== 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]
== 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]
== 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个旋转角度,因此本例最容易出现问题的地方就在于不同形状方块的计算上,需要多加注意。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: