Author Topic: A simple chess board  (Read 1584 times)

jj2007

  • Guest
A simple chess board
« on: December 31, 2015, 12:55:56 PM »
GuiParas equ "A simple Chessboard", x100, y-20, w800, h760, cblack, s0, bnone
include \masm32\MasmBasic\Res\MbGui.asm
  SetGlobals White$, Black$, Board$
  Let Board$="Board.png"
  .if !Exist(Board$)
      void FileRead$("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Chess_Board.svg/768px-Chess_Board.svg.png")
      Rename "~FrLocal.tmp", Board$
  .endif
  MakeFont ChessFont, Height:84
Let White$="♖♘♗♔♕♗♘♖♙♙♙♙♙♙♙♙"
Let Black$="♜♞♝♚♛♝♞♜♟♟♟♟♟♟♟♟"
Event Paint
  GuiImage Board$, fit            ; we need to scale it a little bit
  GuiTextStyle font ChessFont, fcol RgbCol(255, 128, 0)
  invoke SetBkMode, PtDC, TRANSPARENT
  scaleX=33      ; some fiddling with
  scaleY=92      ; image dimensions
  xoff=-15
  y1=5
  y2=y1+scaleY
  y7=y1+scaleY*6
  y8=y1+scaleY*7
  For_ ecx=1 To 21 Step 3
      GuiText ecx*scaleX+xoff, y1, Mid$(White$, ecx, 3)
      GuiText ecx*scaleX+xoff, y2, Mid$(White$, ecx+24, 3)
      GuiText ecx*scaleX+xoff, y7, Mid$(Black$, ecx+24, 3)
      GuiText ecx*scaleX+xoff, y8, Mid$(Black$, ecx, 3)
  Next
GuiEnd


Source & exe attached, requires MasmBasic.