首 页免费资源建站技术源码下载软件下载精品淘吧客户留言
用户登陆 | 用户注册
您当前的位置:笃志小屋建站技术网页设计Flash → 文章内容
Flash MX 编程深层次应用-网络连线游戏(8)
作者:佚名  来源:不详  发布时间:2007-9-11 0:26:23

7.5 实时下棋(2)

    

4.检查哪方胜利的程序

检查哪方胜利的程序如下:

function check_win(row, col, val) {

    var i = col, count = 0;

    // 先检查行连成四子

    while (_root.chess[row][i] == val and i>=0) {

             count++;

             i--;

    }

    if (count>=4) {

             return true;

    }

    i = col+1;

    while (_root.chess[row][i] == val and i<=6) {

             count++;

             i++;

    }

    if (count>=4) {

             return true;

    }

    // 再检查列连成四子

    count = 0;

    i = row;

    while (_root.chess[i][col] == val and i<=5) {

             count++;

             i++;

    }

    if (count>=4) {

             return true;

    }

    // 检查左高斜线

    count = 0;

    i = row;

    j = col;

    while (_root.chess[i][j] == val and i>=0 and j>=0) {

             count++;

             i--;

             j--;

    }

    if (count>=4) {

             return true;

    }

    i = row+1;

    j = col+1;

    while (_root.chess[i][j] == val and i<=5 and j<=6) {

             count++;

             i++;

             j++;

    }

    if (count>=4) {

             return true;

    }

    // 检查右高斜线

    count = 0;

    i = row;

    j = col;

    while (_root.chess[i][j] == val and i>=0 and j<=6) {

             count++;

             i--;

             j++;

    }

    if (count>=4) {

             return true;

    }

    i = row+1;

    j = col-1;

    while (_root.chess[i][j] == val and i<=5 and j>=0) {

             count++;

             i++;

             j--;

    }

    if (count>=4) {

             return true;

    }

}



2007-9-11 0:26:23免费资源duzhi.net

[ ] [返回上一页] [打 印]

【笃志小屋duzhi.net】

  技术文章导航
  技术文章排行
  精彩推荐
Copyright www.duzhi.net All Right Reserved.
设计制作:翼迅设计室 Equick Desgin Home 在线QQ:303471038
网络备案号:冀ICP备06008201号 站长信箱:webmaster#duzhi.net(将#换为@)
本站部分文章和图片来源于网络和内容提供伙伴,如果侵犯了您的权利,请留言告知,本站定会及时删除相关文件!