资源描述:
《中国象棋(代码)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、中国象棋(web版源代码)程序:usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem
2、.Xml.Linq;usingSystem.Data.SqlClient;namespaceWebApplication1{publicpartialclassWebForm1:System.Web.UI.Page{inttru=20;intfals=40;publicImageButton[,]_Image=newImageButton[11,10];//将上一次点击点的坐标保存到数据库中的lastx和lastypublicvoidSaveToLast(){if(Session["user"].ToString()=="red"&&_GetUserState(Se
3、ssion["user"].ToString())==20){intx,y,lastx,lasty;x=Getpointx();y=Getpointy();lastx=x;lasty=y;Updatalastx(lastx);Updatalasty(lasty);}if(Session["user"].ToString()=="black"&&_GetUserState(Session["user"].ToString())==20){intx,y,lastx,lasty;x=Getpointx();y=Getpointy();lastx=x;lasty=y;Upd
4、atalastx(lastx);Updatalasty(lasty);}}//将棋盘上所有棋子图片显示到棋盘上privatevoid_Drawqizi(){//_Init();inti,j,k;if(_GetUserState("red")!=0&&_GetUserState("black")!=0){if(Session["user"].ToString()=="red"){for(i=1;i<=10;i++)for(j=1;j<=9;j++){k=_GetDataQipan(i,j);_Image[i,j].ImageUrl=_GetImageAdd(k);}}
5、if(Session["user"].ToString()=="black"){for(i=1;i<=10;i++)for(j=1;j<=9;j++){k=_GetDataQipan(i,j);_Image[11-i,10-j].ImageUrl=_GetImageAdd(k);}}}//初始化:对_Image[,]赋值,对ImageButton进行编号privatevoid_Init(){_Image[1,1]=ImageButton1;_Image[1,2]=ImageButton2;_Image[1,3]=ImageButton3;_Image[1,4]=Im
6、ageButton4;_Image[1,5]=ImageButton5;_Image[1,6]=ImageButton6;_Image[1,7]=ImageButton7;_Image[1,8]=ImageButton8;_Image[1,9]=ImageButton9;_Image[2,1]=ImageButton11;_Image[2,2]=ImageButton12;_Image[2,3]=ImageButton13;_Image[2,4]=ImageButton14;_Image[2,5]=ImageButton15;_Image[2,6]=ImageBut
7、ton16;_Image[2,7]=ImageButton17;_Image[2,8]=ImageButton18;_Image[2,9]=ImageButton19;_Image[3,1]=ImageButton21;_Image[3,2]=ImageButton22;_Image[3,3]=ImageButton23;_Image[3,4]=ImageButton24;_Image[3,5]=ImageButton25;_Image[3,6]=ImageButton26;_Image[3,7]=ImageButton27;_Image[3,8]=ImageB