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

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

系統 1773 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條評論
主站蜘蛛池模板: 三江| 通州市| 江陵县| 太谷县| 丰原市| 甘泉县| 定襄县| 繁峙县| 闽侯县| 河津市| 灵武市| 新蔡县| 山东| 石楼县| 安远县| 安庆市| 湘乡市| 柘城县| 屏东市| 达孜县| 昌乐县| 临潭县| 木兰县| 齐齐哈尔市| 张家界市| 贺州市| 东明县| 镇安县| 汝阳县| 靖宇县| 彭州市| 郧西县| 高要市| 宜兴市| 平凉市| 彭州市| 民和| 绿春县| 高阳县| 弋阳县| 临武县|