kart442 Posted October 30, 2007 Share Posted October 30, 2007 Just can't seem to get this to work... Thanks for your help. #include <Array.au3> For $board_x = 1 To 8 For $board_y = 1 To 8 $size_x = 63 $size_y = 63 $start_x = 677 $start_y = 686 $x_coord = (($board_x * $size_x) + $start_x) <= 1118 $y_coord = ($start_y - ($board_y * $size_y)) >= 245 Dim $pixel[$x_coord][$y_coord] For $x = 0 To ($x_coord) For $y = 0 To ($y_coord) $pixel[$x][$y] = (PixelGetColor($x, $y)) Next Next Next Next Link to comment Share on other sites More sharing options...
BrettF Posted October 30, 2007 Share Posted October 30, 2007 #include <Array.au3> For $board_x = 1 To 8 For $board_y = 1 To 8 $size_x = 63 $size_y = 63 $start_x = 677 $start_y = 686 $x_coord = (($board_x * $size_x) + $start_x) <= 1118 $y_coord = ($start_y - ($board_y * $size_y)) >= 245 Dim $pixel[$x_coord + 1][$y_coord + 1] For $x = 0 To ($x_coord) For $y = 0 To ($y_coord) $pixel[$x][$y] = (PixelGetColor($x, $y)) Next Next Next Next Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
kart442 Posted October 30, 2007 Author Share Posted October 30, 2007 (edited) #include <Array.au3> For $board_x = 1 To 8 For $board_y = 1 To 8 $size_x = 63 $size_y = 63 $start_x = 677 $start_y = 686 $x_coord = (($board_x * $size_x) + $start_x) <= 1118 $y_coord = ($start_y - ($board_y * $size_y)) >= 245 Dim $pixe[color=[$x_coord + 1][$y_coord + 1] For $x = 0 To ($x_coord) For $y = 0 To ($y_coord) $pixel[$x][$y] = (PixelGetColor($x, $y)) Next Next Next Next Thanks, Didn't know you could put [+1] there, but I have another problem it only returns [2][2] and not [8][8] (need all 64 squares) any suggestions? Edited October 30, 2007 by kart442 Link to comment Share on other sites More sharing options...
BrettF Posted October 30, 2007 Share Posted October 30, 2007 (edited) Would it not be something to do with this line?$x_coord = (($board_x * $size_x) + $start_x) <= 1118 $y_coord = ($start_y - ($board_y * $size_y)) >= 245I'm unsure if you can do 2 expressions there? (The expression on the end) Edited October 30, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
kart442 Posted October 30, 2007 Author Share Posted October 30, 2007 Would it not be something to do with this line? $x_coord = (($board_x * $size_x) + $start_x) <= 1118 $y_coord = ($start_y - ($board_y * $size_y)) >= 245 I'm unsure if you can do 2 expressions there? (The expression on the end)It did change but it came back with [740][250]!!!! Link to comment Share on other sites More sharing options...
BrettF Posted October 30, 2007 Share Posted October 30, 2007 (edited) It did change but it came back with [740][250]!!!! what is start_x and y's purpose? Edited October 30, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Developers Jos Posted October 30, 2007 Developers Share Posted October 30, 2007 what are these statements supposed to do ? your current version will return 1 or 0 (boolean) since you are comparing ... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
kart442 Posted October 30, 2007 Author Share Posted October 30, 2007 Maybe I going about this all wrong? I would like to read the pieces of a chess board (all at the same time) so I can use that info to make a move. 677 is my starting x coord 686 is my starting y coord each square is 63x63 pixels 8 rows 8 cols Link to comment Share on other sites More sharing options...
weaponx Posted October 30, 2007 Share Posted October 30, 2007 You shouldn't be using the pixel functions at all. You should have an 8x8 array representing every position on the board with a unique identifier for each piece. Ever since you posted the first topic about chess I began working on a checkers game, look at this beta code: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 Author: WeaponX Script Function: Checkers Script Version: Pre-Alpha #ce ---------------------------------------------------------------------------- #include <GUIConstants.au3> Dim $boardRows = 8, $boardCols = 8 Dim $boardArray[$boardRows][$boardCols] Dim $boardWidth = 400, $boardHeight = 400 Dim $boardColor1 = 0x333333, $boardColor2 = 0xcccccc Dim $pieceColor1 = 0xcc0000, $pieceColor2 = 0x6699cc GUICreate("Checkers", $boardWidth, $boardHeight) $boardGraphic = GUICtrlCreateGraphic (0,0, $boardWidth, $boardHeight) ;GUICtrlSetBkColor(-1,0x000000) ;GUICtrlSetGraphic(-1,$GUI_GR_COLOR, "",0xfe0002) $flipColor = false For $X = 0 To 7 For $Y = 0 to 7 If $flipColor Then ;Draw square color1 GUICtrlSetGraphic($boardGraphic,$GUI_GR_COLOR, $boardColor1,$boardColor1) $flipColor = false Else ;Draw square color2 GUICtrlSetGraphic($boardGraphic,$GUI_GR_COLOR, $boardColor2,$boardColor2) $flipColor = true EndIf GUICtrlSetGraphic($boardGraphic,$GUI_GR_RECT, $Y * ($boardWidth / $boardCols),$X * ($boardHeight / $boardRows), $boardWidth / $boardCols,$boardHeight / $boardRows) Next If $flipColor Then $flipColor = false Else $flipColor = true EndIf Next ;Must be after all GUICtrlCreateGraphic unless refresh option is used GUISetState (@SW_SHOW) redraw() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func redraw() ;Draw set 1 $flipColor = false For $X = 0 To 2 For $Y = 0 to 7 If $flipColor Then ;Draw piece ;GUICtrlSetColor (-1, $pieceColor2) $flipColor = false Else ;Draw piece GUICtrlCreateLabel ( "l", $Y * ($boardWidth / $boardRows),$X * ($boardHeight / $boardCols), $boardWidth / $boardCols,$boardHeight / $boardRows, $SS_CENTER ) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 34, "", "", "Wingdings") GUICtrlSetColor (-1, $pieceColor1) $flipColor = true EndIf Next If $flipColor Then $flipColor = false Else $flipColor = true EndIf Next ;Draw set 2 $flipColor = false For $X = 5 To 7 For $Y = 0 to 7 If $flipColor Then ;Draw piece GUICtrlCreateLabel ( "l", $Y * ($boardWidth / $boardRows),$X * ($boardHeight / $boardCols), $boardWidth / $boardCols,$boardHeight / $boardRows, $SS_CENTER ) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 34, "", "", "Wingdings") GUICtrlSetColor (-1, $pieceColor2) $flipColor = false Else ;Draw piece ;GUICtrlSetColor (-1, $pieceColor1) $flipColor = true EndIf Next If $flipColor Then $flipColor = false Else $flipColor = true EndIf Next EndFunc 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