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

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

系統(tǒng) 1692 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:新建一個(gè)Movie clip組件,并命名為bb,此組件用來計(jì)算電腦如何走棋,進(jìn)入組件編輯狀態(tài)后,在圖層layer1繪制一個(gè)有填充色的矩形,然后在第5楨插入一個(gè)關(guān)鍵楨,在同樣位置繪制一個(gè)大小相同填充色不同的矩形。新建一個(gè)圖層,在矩形里輸入提示文字:電腦走棋,然后再新建一個(gè)圖層Action,在第一楨添加AS: stop();,在第8楨插入一個(gè)關(guān)鍵楨,在此楨添加如下AS:
if (_root.playnow == "computer") {
//初始化棋盤
_root.func.makelist("white");
_root.func.makelist("black");
//調(diào)用自定義函數(shù)
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";
}
}
}
// 游戲結(jié)束
if (_root.playnow =="nobody") {
_root.gameoverman.gotoAndPlay(2);
}
}
最后的時(shí)間線如圖6所示:

本文轉(zhuǎn)自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/797.html

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


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

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

【本文對(duì)您有幫助就好】

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

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 寿光市| 龙江县| 广平县| 儋州市| 牙克石市| 江阴市| 龙江县| 施秉县| 冕宁县| 柘城县| 巍山| 阿勒泰市| 英超| 芦山县| 南通市| 昭平县| 柯坪县| 梁河县| 辽阳市| 布拖县| 双城市| 天台县| 越西县| 噶尔县| 林口县| 介休市| 辛集市| 广丰县| 普宁市| 西吉县| 二手房| 镇安县| 崇礼县| 昭平县| 庆元县| 西乌| 丹棱县| 泰安市| 峨山| 蒙城县| 会泽县|