VB Code:
Sub SetPiece( _
ByVal p As Piece, _
ByVal ToX As Integer, ByVal ToY As Integer _
)
ChessBoard(ToX, ToY).Figure = p.Figure
ChessBoard(ToX, ToY).Color = p.Color
Set ChessBoardImage(8 * (ToY - 1) + ToX - 1).Picture = _
PieceImages(p.Figure + 6 * Iif(p.Color = COLOR_WHITE, 0, 1)).Picture
End Sub
Sub MovePiece( _
ByVal FromX As Integer, ByVal FromY As Integer, _
ByVal ToX As Integer, ByVal ToY As Integer _
)
'make the destination show the piece
ChessBoard(ToX, ToY).Figure = ChessBoard(FromX, FromY).Figure
ChessBoard(ToX, ToY).Color = ChessBoard(FromX, FromY).Color
Set ChessBoardImage(8 * (ToY - 1) + ToX - 1).Picture = _
ChessBoardImage(8 * (FromY - 1) + FromX - 1).Picture
'delete from the origin
ChessBoard(FromX, FromY).Figure = FIG_NONE
ChessBoard(FromX, FromY).Color = COLOR_NONE
Set ChessBoardImage(8 * (FromY - 1) + FromX - 1).Picture = Nothing
End Sub
the problem that you have, i.e. what piece do i have in the square X and Y, is simply checking the values for ChessBoard(X, Y).Figure and ChessBoard(X, Y).Color. the .Figure will take values like FIG_NONE, FIG_PAWN, FIG_TOWER and so on (constants from 0 to 6) and .Color will be COLOR_NONE, COLOR_WHITE or COLOR_BLACK (constants from 0 to 2).