Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- global $space, $end, $endx, $redraw, $boardw[32], $fields[64], $log, $user32 = DllOpen("user32")
- ;---config---
- $circle=50 ;board size
- ;------------
- ;---fill-board---
- $beginswb=$circle/0.134408602150538
- $i=0
- while $i<64
- $beginswa=$circle/2.27272727272727
- $ii=0
- while $ii<8
- $fields[$i]=$beginswa & "_" & $beginswb
- $beginswa=$beginswa+$circle
- $ii=$ii+1
- $i=$i+1
- WEnd
- $beginswb=$beginswb-$circle
- WEnd
- ;---white---
- $beginswa=$circle/2.27272727272727
- $beginswb=$circle/0.134408602150538
- $boardw[0]="w_" & $beginswa & "_" & $beginswb & "_t_y"
- $beginswa=$beginswa+$circle
- $boardw[1]="w_" & $beginswa & "_" & $beginswb & "_s_y"
- $beginswa=$beginswa+$circle
- $boardw[2]="w_" & $beginswa & "_" & $beginswb & "_l_y"
- $beginswa=$beginswa+$circle
- $boardw[3]="w_" & $beginswa & "_" & $beginswb & "_d_y"
- $beginswa=$beginswa+$circle
- $boardw[4]="w_" & $beginswa & "_" & $beginswb & "_k_y"
- $beginswa=$beginswa+$circle
- $boardw[5]="w_" & $beginswa & "_" & $beginswb & "_l_y"
- $beginswa=$beginswa+$circle
- $boardw[6]="w_" & $beginswa & "_" & $beginswb & "_s_y"
- $beginswa=$beginswa+$circle
- $boardw[7]="w_" & $beginswa & "_" & $beginswb & "_t_y"
- $beginswa=$circle/2.27272727272727
- $beginswb=$beginswb-$circle
- $i=8
- while $i<16
- $boardw[$i]="w_" & $beginswa & "_" & $beginswb & "_b_y"
- $beginswa=$beginswa+$circle
- $i=$i+1
- WEnd
- ;-----------
- ;---black---
- $beginswa=$circle/2.27272727272727
- $beginswb=$beginswb-$circle*6
- $boardw[16]="b_" & $beginswa & "_" & $beginswb & "_t_y"
- $beginswa=$beginswa+$circle
- $boardw[17]="b_" & $beginswa & "_" & $beginswb & "_s_y"
- $beginswa=$beginswa+$circle
- $boardw[18]="b_" & $beginswa & "_" & $beginswb & "_l_y"
- $beginswa=$beginswa+$circle
- $boardw[19]="b_" & $beginswa & "_" & $beginswb & "_d_y"
- $beginswa=$beginswa+$circle
- $boardw[20]="b_" & $beginswa & "_" & $beginswb & "_k_y"
- $beginswa=$beginswa+$circle
- $boardw[21]="b_" & $beginswa & "_" & $beginswb & "_l_y"
- $beginswa=$beginswa+$circle
- $boardw[22]="b_" & $beginswa & "_" & $beginswb & "_s_y"
- $beginswa=$beginswa+$circle
- $boardw[23]="b_" & $beginswa & "_" & $beginswb & "_t_y"
- $beginswa=$circle/2.27272727272727
- $beginswb=$beginswb+$circle
- $i=24
- while $i<32
- $boardw[$i]="b_" & $beginswa & "_" & $beginswb & "_b_y"
- $beginswa=$beginswa+$circle
- $i=$i+1
- WEnd
- ;-----------
- ;----------------
- #include <GDIPlus.au3>
- #include <WindowsConstants.au3>
- #include <GuiConstantsEx.au3>
- Opt("GUIOnEventMode", 1)
- $space=$circle/2.5
- $full=$circle*8
- $end=$space+$full
- $endx=$space*2+$full
- OnAutoItExitRegister("end")
- $redraw="a"
- $marked="a"
- $bg=GUICreate("chess", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
- GUISetBkColor(0xF0F0F0)
- GUISetState(@SW_SHOW, $bg)
- While 1
- ;---redraw---
- if $redraw=="a" Then
- $hGUI=GUICreate("chess", $endx, $endx, -1, -1, $WS_POPUP)
- GUISetBkColor(0xD3D3D3)
- GUISetOnEvent(-3, "end")
- GUISetState()
- _GDIPlus_Startup()
- $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
- $hBrushb = _GDIPlus_BrushCreateSolid(0xAACE9E00)
- $hBrushw = _GDIPlus_BrushCreateSolid(0xD18B4700)
- local $j[8]
- $j[0]="A"
- $j[1]="B"
- $j[2]="C"
- $j[3]="D"
- $j[4]="E"
- $j[5]="F"
- $j[6]="G"
- $j[7]="H"
- $endj=$end+$space/10
- $font=$circle/5
- $ia=0
- $i=$circle-($space/2)
- While $ia<8
- _GDIPlus_GraphicsDrawString($hGraphic, $j[$ia], $i, $endj, "Arial", $font)
- $ia=$ia+1
- $i=$i+$circle
- WEnd
- $endjx=$space/4
- $ia=8
- $i=$circle-($space/2)
- While $ia>0
- _GDIPlus_GraphicsDrawString($hGraphic, $ia, $endjx, $i, "Arial", $font)
- $ia=$ia-1
- $i=$i+$circle
- WEnd
- $iii="a"
- $ii=$space
- while $ii<$end
- $i=$space
- while $i<$end
- if $iii=="a" Then
- _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushb)
- $i=$i+$circle
- _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushw)
- $i=$i+$circle
- Else
- _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushw)
- $i=$i+$circle
- _GDIPlus_GraphicsFillRect($hGraphic, $i, $ii, $circle, $circle, $hBrushb)
- $i=$i+$circle
- EndIf
- WEnd
- if $iii=="a" Then
- $iii="b"
- Else
- $iii="a"
- EndIf
- $ii=$ii+$circle
- WEnd
- ;----------------
- local $hImage, $drawi
- $figures=$circle/1.08695652173913
- ;---white---
- $drawi=StringSplit($boardw[0], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="t" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_tower.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[1], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="s" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_horse.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- endif
- $drawi=StringSplit($boardw[2], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="l" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_runner.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[3], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="d" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_queen.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[4], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="k" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_king.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[5], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="l" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_runner.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[6], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="s" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_horse.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[7], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="t" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_tower.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $i=8
- while $i<16
- $drawi=StringSplit($boardw[$i], "_", 1)
- if $drawi[1]=="w" and $drawi[4]=="b" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("w_pawn.png")
- _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $i=$i+1
- WEnd
- ;-----------
- ;---black---
- $drawi=StringSplit($boardw[16], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="t" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_tower.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[17], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="s" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_horse.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- endif
- $drawi=StringSplit($boardw[18], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="l" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_runner.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[19], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="d" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_queen.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[20], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="k" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_king.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[21], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="l" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_runner.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[22], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="s" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_horse.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $drawi=StringSplit($boardw[23], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="t" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_tower.png")
- _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $i=24
- while $i<32
- $drawi=StringSplit($boardw[$i], "_", 1)
- if $drawi[1]=="b" and $drawi[4]=="b" and $drawi[5]=="y" Then
- $hImage = _GDIPlus_ImageLoadFromFile("b_pawn.png")
- _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0, 120, 120, $drawi[2], $drawi[3], $figures, $figures)
- EndIf
- $i=$i+1
- WEnd
- ;-----------
- $redraw="b"
- EndIf
- ;------------
- $winpos = WinGetPos($hGUI)
- $pos=MouseGetPos()
- $posa=$pos[0]
- $posb=$pos[1]
- $pos[0]=$pos[0]-$winpos[0]
- $pos[1]=$pos[1]-$winpos[1]
- if $pos[0]<1 Then
- MouseMove($posa+3, $posb, 0)
- EndIf
- if $pos[0]>$endx Then
- MouseMove($posa-3, $posb, 0)
- EndIf
- if $pos[1]<1 Then
- MouseMove($posa, $posb+3, 0)
- EndIf
- if $pos[1]>$endx Then
- MouseMove($posa, $posb-3, 0)
- EndIf
- if _IsPressed('01') = 1 Then
- ;---check-field---
- $i=0
- while $i<64
- $drawi=StringSplit($fields[$i], "_", 1)
- if $pos[0]>$drawi[1] and $pos[0]<$drawi[1]+$figures and $pos[1]>$drawi[2] and $pos[1]<$drawi[2]+$figures Then
- if $marked=="b" Then
- $ia=0
- while $ia<32
- if $boardwx==$boardw[$ia] Then
- $drawix=StringSplit($boardw[$ia], "_", 1)
- $search=$drawix[1] & "_" & $drawi[1] & "_" & $drawi[2] & "_"
- $ix=0
- while $ix<32
- if StringInStr($boardw[$ix], $search, 1) Then
- ExitLoop
- EndIf
- $ix=$ix+1
- WEnd
- ;---rules---
- $next="a"
- $beginswbx=$circle/0.134408602150538
- $beginswbx=$beginswbx-$circle
- ;---pawn-white---
- if $drawix[1]=="w" and $drawix[4]=="b" Then
- if $ix>31 Then
- if $drawix[2]<>$drawi[1] Then
- msgbox(4096, "error", "incorrect usage0")
- Else
- if $beginswbx==$drawix[3] Then
- $ker=$circle*2
- Else
- $ker=$circle
- EndIf
- if $drawix[3]<$drawi[2] or $drawix[3]>$drawi[2]+$ker Then
- msgbox(4096, "error", "incorrect usage1")
- Else
- $next="b"
- EndIf
- EndIf
- Else
- msgbox(4096, "error", "incorrect usage2")
- endif
- EndIf
- ;----------------
- ;---pawn-black---
- $beginswbx=$beginswbx-$circle*6
- $beginswbx=$beginswbx+$circle
- if $drawix[1]=="b" and $drawix[4]=="b" Then
- if $ix>31 Then
- if $drawix[2]<>$drawi[1] Then
- msgbox(4096, "error", "incorrect usage3")
- Else
- if $beginswbx==$drawix[3] Then
- $ker=$circle*2
- Else
- $ker=$circle
- EndIf
- ;-------------------------------------------------------------------------------------------here
- if $drawix[3]>$drawi[2] Then
- msgbox(4096, "...", "if (" & $drawix[3] & ">" & $drawi[2] & ") { thats true o.0 }")
- EndIf
- ConsoleWrite("if (" & $drawix[3] & ">" & $drawi[2] & ") { thats true o.0 }")
- ;-----------------------------------------------------------------------------------------------
- if $drawix[3]+$ker<$drawi[2] Then
- msgbox(4096, "error", "incorrect usage4")
- Else
- $next="b"
- EndIf
- EndIf
- Else
- msgbox(4096, "error", "incorrect usage5")
- endif
- EndIf
- ;----------------
- ;-----------
- if $next="b" then
- $boardw[$ia]=$drawix[1] & "_" & $drawi[1] & "_" & $drawi[2] & "_" & $drawix[4] & "_" & $drawix[5]
- EndIf
- ExitLoop
- EndIf
- $ia=$ia+1
- WEnd
- _GDIPlus_BrushDispose($hBrushw)
- _GDIPlus_BrushDispose($hBrushb)
- _GDIPlus_GraphicsDispose($hGraphic)
- _GDIPlus_PenDispose($hPenmark)
- _GDIPlus_GraphicsDispose($hGraphicmark)
- _GDIPlus_Shutdown()
- guidelete($hGUI)
- $redraw="a"
- $marked="a"
- EndIf
- EndIf
- $i=$i+1
- WEnd
- ;-----------------
- ;---find-figure---
- $i=0
- while $i<32
- $drawi=StringSplit($boardw[$i], "_", 1)
- if $pos[0]>$drawi[2] and $pos[0]<$drawi[2]+$figures and $pos[1]>$drawi[3] and $pos[1]<$drawi[3]+$figures Then
- if $marked=="a" and $redraw=="b" Then
- $hGraphicmark = _GDIPlus_GraphicsCreateFromHWND($hGUI)
- $hPenmark = _GDIPlus_PenCreate(0xAF50FF00, $circle/25)
- _GDIPlus_GraphicsDrawArc($hGraphicmark, $drawi[2]-($figures/($circle/2)), $drawi[3]-($figures/($circle/2)), $circle, $circle, 180, 360, $hPenmark)
- $boardwx=$boardw[$i]
- $marked="b"
- EndIf
- EndIf
- $i=$i+1
- WEnd
- sleep(100)
- EndIf
- WEnd
- ;-----------------
- Func _IsPressed($hexKey)
- Local $aR, $bRv
- $hexKey = '0x' & $hexKey
- $aR = DllCall($user32, "int", "GetAsyncKeyState", "int", $hexKey)
- if $aR[0] <> 0 Then
- $bRv = 1
- Else
- $bRv = 0
- EndIf
- Return $bRv
- EndFunc
- func end()
- _GDIPlus_BrushDispose($hBrushw)
- _GDIPlus_GraphicsDispose($hGraphic)
- _GDIPlus_Shutdown()
- Exit
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement