This program is for my students to do a chess game, which involves all interested friends can download to see
It draws a virtual grid, where the grid distribution is 9x10 distribution, and normal chess layout, that is, gridx,gridy as the x,y coordinates of the grid, all coordinate points are converted using this virtual grid
It defines a piece interface, and all the interactions between the board and the pieces come from this interface.
public interface Ichessitem
{
/**////<summary>
///to Blue or red to
///</summary>
Enums.chesstype Type{get;set;}
/**////<summary>
///is pressed
///</summary>
BOOL Ischecked{get;set;
/**////<summary>
///move step x
///</summary>
int stepx{get;}
/**////<summary>
///move step y
///</summary>
int stepy{get;}
/**////<summary>
///The x-coordinate of the checkerboard grid
///</summary>
int gridx{get;set;}
/**////<summary>
///The y-coordinate in the checkerboard grid
///</summary>
int gridy{get;set;}
/**////<summary>
///Move Pawn
///</summary>
///<param name= "CHESSX" > grid x coordinates to be moved </ Param>
///<param name= "Chessy" > The grid y-coordinate to be moved </param>
///<returns> whether to move successfully </returns>
BOOL MoveItem (int chessx,int chessy);
/**////<summary>
///Initialize the pawn
///</summary>
void Inititem ();
/**////<summary>
///to remove the pawn as it is eaten by another pawn
///</summary>
void Remove ();
}
There are two more important events private void Cib_click (object sender, EventArgs e) This event for the pawn to click the event, by which to respond to the selection of pieces and eat other pieces, the name did not change, oh, sorry
private void Form1_mousedown (object sender, System.Windows.Forms.MouseEventArgs e) This event is moved as a pawn
All pieces are moved from the Ichessitem interface.
BOOL MoveItem (int chessx,int chessy);
Because it is for my students to see, this program is simpler, so the flow is relatively simple. Learn C # friends can look at, hehe
One of the algorithms trouble is the cannon of the turn of the mountain, the horse's lame, like the lame
All pieces inherit chessitembase, some of which override the function public virtual bool Limitpoint (int chessx,int Chessy) to achieve their own special restrictions to move, such as artillery, horses, elephants, soldiers, etc.
Demo Soure Http://www.cnblogs.com/Files/KeithDan/Chess.rar
Http://www.cnblogs.com/KeithDan/archive/2006/12/06/583472.html