日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Flash游戲制作--五子連珠(二)

系統 1798 0

// 顯示棋子
_root.display = "Xpos : " + (x + 1);
temp = chr ( y + 65);
_root.display1 = "Ypos : " + temp;
_root.playnow = "player";
//判斷是否獲勝
xx = x;
yy = y;
for (k=0; k 6) {
_root.a_result = 0;
x = xx;
y = yy;
while ((_root.table[y][x] == 2) and (y+_root.dir[k][1] = -1) and (x+_root.dir[k][0] = -1)) {
x = x + _root.dir[k][0];
y = y + _root.dir[k][1];
// "_root.table["+y+"]["+x+"]="+_root.table[y][x]
_root.a_result = _root.a_result+1;
}
x = xx;
y = yy;
while ((_root.table[y][x] == 2) and (y+_root.dir[k+4][1] = -1) and (x+_root.dir[k+4][0] = -1)) {
x = x + _root.dir[k+4][0];
y = y + _root.dir[k+4][1];
_root.a_result = _root.a_result+1;
}
if (_root.a_result == 6) {
_root.playnow = "nobody";
}
}
}
if (_root.playnow =="nobody") {
_root.gameoverman.gotoAndPlay(2);
}
}
C:新建一個Movie clip組件,并命名為bb,此組件用來計算電腦如何走棋,進入組件編輯狀態后,在圖層layer1繪制一個有填充色的矩形,然后在第5楨插入一個關鍵楨,在同樣位置繪制一個大小相同填充色不同的矩形。新建一個圖層,在矩形里輸入提示文字:電腦走棋,然后再新建一個圖層Action,在第一楨添加AS: stop();,在第8楨插入一個關鍵楨,在此楨添加如下AS:
if (_root.playnow == "computer") {
//初始化棋盤
_root.func.makelist("white");
_root.func.makelist("black");
//調用自定義函數
max_computer = 0;
max_player = 0;
k = 0;
//定義三變量
for (j=0; j 50) {
max_computer = _root.computer[j*15+i][k] ;
xc = i;
yc = j;
}
}
if (_root.computer[j*15+i][k] > max_computer) {
max_computer = _root.computer[j*15+i][k] ;
xc = i;
yc = j;
}
if (_root.player[j*15+i][k] > max_player) {
max_player = _root.player[j*15+i][k] ;
xp = i;
yp = j;
}
}
}
}
if (max_computer > max_player) {
x = xc;
y = yc;
} else {
x = xp;
y = yp;
}
// 繪制棋子
num = y * 15 + x;
removeMovieClip(_root.b add num);
duplicateMovieClip(_root.white, "white" add num, num + 300);
setProperty(_root.white add num, _x, 34.7 + x * 20);
setProperty(_root.white add num, _y, 34.7 + y * 20);
_root.table[y][x] = 2;
// 顯示棋子
_root.display = "Xpos : " + (x + 1);
temp = chr ( y + 65);
_root.display1 = "Ypos : " + temp;
_root.playnow = "player";
// 判斷是否獲勝
xx = x;
yy = y;
for (k=0; k 6) {
_root.a_result = 0;
x = xx;
y = yy;
while ((_root.table[y][x] == 2) and (y+_root.dir[k][1] = -1) and (x+_root.dir[k][0] = -1)) {
x = x + _root.dir[k][0];
y = y + _root.dir[k][1];
// "_root.table["+y+"]["+x+"]="+_root.table[y][x]
_root.a_result = _root.a_result+1;
}
x = xx;
y = yy;
while ((_root.table[y][x] == 2) and (y+_root.dir[k+4][1] = -1) and (x+_root.dir[k+4][0] = -1)) {
x = x + _root.dir[k+4][0];
y = y + _root.dir[k+4][1];
_root.a_result = _root.a_result+1;
}
?
if (_root.a_result == 6) {
_root.playnow = "nobody";
}
}
}
// 游戲結束
if (_root.playnow =="nobody") {
_root.gameoverman.gotoAndPlay(2);
}
}
最后的時間線如圖6所示:

本文轉自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/797.html

Flash游戲制作--五子連珠(二)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 金川县| 昌都县| 新巴尔虎左旗| 冕宁县| 尚志市| 万安县| 屏东县| 宝山区| 安平县| 兴海县| 咸阳市| 沁水县| 宜良县| 宁津县| 包头市| 高尔夫| 泌阳县| 卢湾区| 景洪市| 临沂市| 金平| 安阳市| 德安县| 敦煌市| 将乐县| 石渠县| 阿拉善右旗| 宁晋县| 全椒县| 会东县| 灵川县| 石景山区| 延津县| 鞍山市| 河北区| 陇川县| 遵义市| 九龙坡区| 三明市| 唐海县| 报价|