富贵资源网 Design By www.hznty.com
本文实例讲述了JS小游戏的象棋暗棋源码,分享给大家供大家参考。具体如下:
游戏运行后如下图所示:
Javascript 部分:
/** chinese chess * Author: fdipzone * Date: 2012-06-24 * Ver: 1.0 */ var gameimg = ['images/a1.gif','images/a2.gif','images/a3.gif','images/a4.gif','images/a5.gif','images/a6.gif','images/a7.gif','images/b1.gif','images/b2.gif','images/b3.gif','images/b4.gif','images/b5.gif','images/b6.gif','images/b7.gif','images/bg.gif','images/bg_over.gif','images/bg_sel.gif']; var chess_obj = new ChessClass(); window.onload = function(){ $('init_btn').onclick = function(){ chess_obj.init(); } var callback = function(){ chess_obj.init(); } img_preload(gameimg, callback); } // chess class function ChessClass(){ this.chess = []; this.boardrows = 4; this.boardcols = 8; this.area = 82; this.player = 1; // 1:red 2:green this.selected = null; // selected chess this.chesstype = ['', 'a', 'b']; this.isover = 0; } // init ChessClass.prototype.init = function(){ this.reset_grade(); this.create_board(); this.create_chess(); this.create_event(); this.player = 1; this.selected = null; this.isover = 0; disp('init_div','hide'); } // create board ChessClass.prototype.create_board = function(){ var board = ''; for(var i=0; i<this.boardrows; i++){ for(var j=0; j<this.boardcols; j++){ board = board + '<div id="' + i + '_' + j + '"><img src="/UploadFiles/2021-04-02/chessbg.gif">本站下载。相信本文所述对大家javascript游戏设计的学习有一定的借鉴价值。
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...