attactician Posted April 28, 2008 Share Posted April 28, 2008 Could someone point me in the right direction, I want to create a chess board with peices that can be added or removed, any thoughts? I don't need a chess engine or anything, this should be within the realm of autoit scripting capabilities. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 28, 2008 Share Posted April 28, 2008 if it will get you started then here is your chess board code. expandcollapse popup; GUICreate("Test GUI") Global $xPos = 0, $yPos = 0, $sColor, $Row = 1 For $I = 1 To 64 If Mod($Row, 2) <> 0 Then If Mod($I, 2) = 0 Then $sColor = 0xFFFFFF Else $sColor = 0x000000 EndIf Else If Mod($I, 2) = 0 Then $sColor = 0x000000 Else $sColor = 0xFFFFFF EndIf EndIf _GUI_CreateBox($xPos, $yPos, 50, 50, 1, $sColor) $xPos += 50 If Mod($I, 8) = 0 Then $row += 1 $xPos = 0 $yPos += 50 EndIf Next GUISetState() While 1 If GUIGetMsg() = -3 Then Exit Wend Func _GUI_CreateBox($xStart, $yStart, $bWidth, $bHeight, $bThick = 1, $cFill = default, $cLine = 0x000000) Local $Fill, $Left, $Top, $Bottom, $Right If $cFill <> default Then $Fill = GUICtrlCreateLabel("", $xStart, $yStart, $bWidth, $bHeight) GUICtrlSetBkColor($Fill, $cFill) EndIf $Left = GUICtrlCreateLabel("", $xStart, $yStart, $bThick, $bHeight + $bThick) $Top = GUICtrlCreateLabel("", $xStart, $yStart, $bWidth, $bThick) $Bottom = GUICtrlCreateLabel("", $xStart, $yStart + $bHeight, $bWidth, $bThick) $Right = GUICtrlCreateLabel("", $xStart + $bWidth, $yStart, $bThick, $bHeight +$bThick) For $I = $Left to $Right GUICtrlSetBkColor($i, $cLine) Next EndFunc ;<==> _GUI_CreateBox() ; George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted April 28, 2008 Share Posted April 28, 2008 (edited) For the board you might even prefer this one. You will have to extract the files from the attached zip to your script dir. expandcollapse popup; GUICreate("Test GUI", 400, 400) Global $xPos = 0, $yPos = 0, $Row = 1, $sImage For $I = 1 To 64 If Mod($Row, 2) <> 0 Then If Mod($I, 2) = 0 Then $sImage = @ScriptDir & "\pine.jpg" Else $sImage = @ScriptDir & "\ash.jpg" EndIf Else If Mod($I, 2) = 0 Then $sImage = @ScriptDir & "\ash.jpg" Else $sImage = @ScriptDir & "\pine.jpg" EndIf EndIf _GUI_CreateImageBox($xPos, $yPos, 50, 50, $sImage, 2) $xPos += 50 If Mod($I, 8) = 0 Then $row += 1 $xPos = 0 $yPos += 50 EndIf Next GUISetState() While 1 If GUIGetMsg() = -3 Then Exit Wend Func _GUI_CreateImageBox($xStart, $yStart, $bWidth, $bHeight, $bImage, $bThick = 1, $cLine = 0x000000) Local $I, $Left, $Top, $Bottom, $Right If Not FileExists($bImage) Then Return SetError(1) GUICtrlCreatePic($bImage, $xStart, $yStart, $bWidth, $bHeight) GUICtrlSetState(-1, 144) $Left = GUICtrlCreateLabel("", $xStart, $yStart, $bThick, $bHeight + $bThick) $Top = GUICtrlCreateLabel("", $xStart, $yStart, $bWidth, $bThick) $Bottom = GUICtrlCreateLabel("", $xStart, $yStart + $bHeight, $bWidth, $bThick) $Right = GUICtrlCreateLabel("", $xStart + $bWidth, $yStart, $bThick, $bHeight +$bThick) For $I = $left To $Right GUICtrlSetBkColor($I, $cLine) GUICtrlSetState($I, 144) Next EndFunc ;<==> _GUI_CreateImageBox() ; Edit: Fixed a possible problem with $I in the function and changed the control states to disabled.Wood_Imgs.zip Edited April 28, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GunsAndRoses Posted April 28, 2008 Share Posted April 28, 2008 (edited) That's Awesome Geosoft. I really would love to see a chess game! EDIT: Hey Geosoft, Would you mind explaining how you actually did the creation of it? This part: For $I = 1 To 64 If Mod($Row, 2) <> 0 Then If Mod($I, 2) = 0 Then $sImage = @ScriptDir & "\pine.jpg" Else $sImage = @ScriptDir & "\ash.jpg" EndIf Else If Mod($I, 2) = 0 Then $sImage = @ScriptDir & "\ash.jpg" Else $sImage = @ScriptDir & "\pine.jpg" EndIf EndIf _GUI_CreateImageBox($xPos, $yPos, 50, 50, $sImage) $xPos += 50 If Mod($I, 8) = 0 Then $row += 1 $xPos = 0 $yPos += 50 EndIf Next It seems really complicated although it might not be. Edited April 28, 2008 by GunsAndRoses Link to comment Share on other sites More sharing options...
GEOSoft Posted April 28, 2008 Share Posted April 28, 2008 That's Awesome Geosoft. I really would love to see a chess game! EDIT: Hey Geosoft, Would you mind explaining how you actually did the creation of it? This part: For $I = 1 To 64 If Mod($Row, 2) <> 0 Then; It's an odd numbered Row If Mod($I, 2) = 0 Then;It's an even numbered Column $sImage = @ScriptDir & "\pine.jpg" Else $sImage = @ScriptDir & "\ash.jpg" EndIf Else If Mod($I, 2) = 0 Then $sImage = @ScriptDir & "\ash.jpg" Else $sImage = @ScriptDir & "\pine.jpg" EndIf EndIf _GUI_CreateImageBox($xPos, $yPos, 50, 50, $sImage) $xPos += 50 If Mod($I, 8) = 0 Then;;We reached the end of the row $row += 1;; Change the Row count $xPos = 0 $yPos += 50;; Move to the next Row position EndIf Next It seems really complicated although it might not be.I just commented the code you quoted. BTW I'm just about to edit that function so check back on my previous reply in a minute or so. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
attactician Posted April 28, 2008 Author Share Posted April 28, 2008 Wow! I guess this chess idea is far from a new one, and it appears to have piqued some interest. Thanks to all those replying to my original inquiry, you have definitely given me a great starting point! I'll keep the forum updated with my progress. I have a interesting chess project in mind, and it may take a while to come to fruition. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 28, 2008 Share Posted April 28, 2008 Wow! I guess this chess idea is far from a new one, and it appears to have piqued some interest. Thanks to all those replying to my original inquiry, you have definitely given me a great starting point! I'll keep the forum updated with my progress. I have a interesting chess project in mind, and it may take a while to come to fruition.No problem.There are a lot of Chess images available for download that may help you some more. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
attactician Posted April 29, 2008 Author Share Posted April 29, 2008 No problem.There are a lot of Chess images available for download that may help you some more.Would that include images of chess peices? I would be interested in checking those out. Do you have a collection I could browse through? Link to comment Share on other sites More sharing options...
GEOSoft Posted April 29, 2008 Share Posted April 29, 2008 (edited) Would that include images of chess peices? I would be interested in checking those out. Do you have a collection I could browse through?I found many when I was Googling for a chess icon a few months back. I had the whole set as PNGs but it appears that I only kept 2 of them and I converted those to icons. By the way, for a better view of that board, Change the GUI size to 600x600 and any reference to "50" becomes 75 as follows (I also changed the border width to 3) ; _GUI_CreateImageBox($xPos, $yPos, 75, 75, $sImage, 3, $bdr) $xPos += 75 If Mod($I, 8) = 0 Then $row += 1 $xPos = 0 $yPos += 75 EndIf ; Edited April 29, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now