Sub ClearBoard
Dim ii As Int
For ii = 0 To 63
Squares(ii).Style=IIf(SqColor(ii)=0,EmptyW,EmptyB)
Next
End Sub
' Squares() is a 64 labels array and EmptyW and EmptyB are initialized as
'EmptyW = Squares(1).Style
'EmptyB = Squares(0).Style
' basically in this way I set the colors of all the square'
' the below sub sets the pieces in the labels looking at the piece in the square
' which is the CurrentPos.Pieces() array, positive pieces are white, neg are black'
Sub PrintBoard
Dim ii,TempPiece As Int
For ii = 0 To 63
TempPiece = CurrentPos.Pieces(ii)
Select Abs(TempPiece)
Case 0
Squares(ii).Style=IIf(SqColor(ii)=0,EmptyW,EmptyB)
Case 1
If TempPiece > 0 Then
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"WK.png")
Else
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"BK.png")
End If
Case 2
If TempPiece > 0 Then
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"WQ.png")
Else
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"BQ.png")
End If
Case 3
If TempPiece > 0 Then
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"WR.png")
Else
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"BR.png")
End If
Case 4
If TempPiece > 0 Then
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"WB.png")
Else
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"BB.png")
End If
Case 5
If TempPiece > 0 Then
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"WN.png")
Else
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"BN.png")
End If
Case 6
If TempPiece > 0 Then
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"WP.png")
Else
CSSUtils.SetBackgroundImage(Squares(ii),File.DirAssets,"BP.png")
End If
End Select
Next
End Sub