Sign in to follow this  
Followers 0
CodyBarrett

GUI Control array for Chess game

25 posts in this topic

i had an idea for a PVP chess game.. i know there is one kicking around here but i would like to do it myself

my problem.. its quite simple really though the answer has escaped me.. obviously since i'm posting here... :) ANYWAY i'm making a Possible move viewer and i figured out PAWN.. and KNIGHT and i'm working on BISHOP but i don't know how to make the Diagonal lines... my Grid is a $Grid[8][8] and when i click on the Bishop i want it to have x's in every possibly spot where it can move.. Diagonally Pawn and Knight work perfectly for me.. but Diagonals is giving me trouble... any ideas guys?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Well I'm a noob AutoIt programmer compared to lots, including you. But I do know what way to lead you to... Though I don't know how to code it exactly.

Pythagorean theorem. a^2 + b^2 = c^2 So take an entire chess board for example. Say it is 10x10 (I know it's not, but you know). If your bishop is 3 spots from the corner, it is at spot 7 and can only move diagonal 7 one way and 3 the other. (10 - $spot (7th spot... or 3rd spot, whichever way you determine it) = $place (would equal the opposite of $spot)

Now you can find your 'c^2'. And what do you know, a and b are found xD. ($place and $spot)

So you would graph it with two directions:

$place^2 + $place^2 = $move^2

$spot^2 + $spot^2 = $move1^2

And you use $place^2 + $place^2 because no matter what spot your at, the other side that completes the angle of the triangle is the exact same. (Say your up on the 3rd row, right in front of your Pawns, 5 spots to the right (in the middle in my example) You start off finding the positive direction which is 5 on side 'a' and 5 on side 'b'. Then just do negative direction.

(and negative values for opposite direction)

Now you have your diagonals, and being a chess board is perfectly dimensional, the diagonal lines should line up hitting the corners of each box.

Maybe I'm babbling and I don't know what I'm talking about. But I used the Pyth theory once to make a path-recorder on an online game I used to play. It would move around the screen acting as if it was a grid, going up, side ways, down, and diagonal (Pyth theory).

Maybe it won't work here, Idk... xD

post-10505-12479760952902_thumb.jpg

Edited by UnknownWarrior

Share this post


Link to post
Share on other sites

okay well.. i made it working for every piece except the queen and bishop which use diagonals... i'm not sure if the above will work or not but i'll look into it

Share this post


Link to post
Share on other sites

okay well.. i made it working for every piece except the queen and bishop which use diagonals... i'm not sure if the above will work or not but i'll look into it

It will work with diagonals for sure... It's just if its the easiest thing...

And nevermind... After I thought about it, a chessboard is 8x8 and the google images were misleading xD. The idea is still there.

Share this post


Link to post
Share on other sites

okay... it doesn't work XD ill post my code lol

also as an afterthought.... in the HF under INT xD i found this...

Remarks

Fractional portions are truncated, so Int(1.999999) returns 1

Int(0/0) returns -9.22337203685478e+018, if you were wondering.

#include <GUICONSTANTS.AU3>
#include <WINDOWSCONSTANTS.AU3>
#include <STATICCONSTANTS.AU3>
#include <EDITCONSTANTS.AU3>
#include <MISC.AU3>
#Include <WinAPI.au3>
Opt ('GUIoneventmode', 1)

_Reset_Misc_Vars_ ()

$sn = StringTrimRight (@ScriptName, 4)
$Bk = 0xFFFFFF
$Fc = 0x0
$x = -40
$ID = 0
$IDv = 0
$MoveStatus = 0
$GUIStyle = BitOR($WS_POPUP, $WS_VISIBLE,$WS_SIZEBOX)
$GUIStyleEx = BitOR ($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)
$LStyle = BitOR ($SS_CENTER, $SS_CENTERIMAGE)
$Edit = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP)
$EditEx = BitOR($ES_READONLY, $ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP)

Dim $Grid[8][8], $GuiGrid[8][8], $Pawn_settings[8][2]

$GUI = GUICreate ($sn, 600, 430, -1, -1,$GUIStyle ,$GUIStyleEx)
GUISetBkColor ($Bk, $GUI)

$lTitleBar = GUICtrlCreateLabel ($Sn, 20, 0, 580, 20, $LStyle)
GUICtrlSetBkColor (-1, $Bk)
GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')
GUICtrlSetColor (-1, $Fc)
GUICtrlSetOnEvent (-1, '_Win_Move_')

$lExit = GUICtrlCreateLabel ('x', 0, 0, 20, 20, $LStyle)
GUICtrlSetBkColor (-1, $Bk)
GUICtrlSetFont (-1, 10, 400, '', 'Fixedsys')
GUICtrlSetColor (-1, $Fc)
GUICtrlSetOnEvent (-1, '_Exit_')
GUICtrlSetCursor (-1, 0)



For $0 = 0 To 7
    $x += 50
    $y = -20
    For $00 = 0 To 7
        $y += 50
        $Grid[$0][$00] = 0
        $GuiGrid[$0][$00] = GUICtrlCreateLabel ('', $x, $y, 40, 40,$LStyle )
        GUICtrlSetFont (-1, 20, 400)
        GUICtrlSetBkColor (-1, $Fc)
        GUICtrlSetCursor (-1, 0)
        GUICtrlSetColor (-1, $Bk)
        GUICtrlSetOnEvent (-1, '_Grid_Evaluate_')
        ;--------Pawn--------
        GUICtrlSetBkColor ($GuiGrid[$0][6], 0x000080)
        $Grid[$0][6] = 6
        $Pawn_settings[$0][0] = $GuiGrid[$0][6]
        $Pawn_settings[$0][1] = 1 ;Still has a two block move.... 0=normal... 2-5=other pieces
    Next
Next
$x = 0
$y = 0
_Reset_Misc_Vars_ ()
;--------King--------
GUICtrlSetBkColor ($GuiGrid[4][7], 0xFF8000)
$Grid[4][7] = 1
;--------Queen--------
GUICtrlSetBkColor ($GuiGrid[3][7], 0xFF80C0)
$Grid[3][7] = 2
;--------Rooks--------
GUICtrlSetBkColor ($GuiGrid[0][7], 0x808080)
GUICtrlSetBkColor ($GuiGrid[7][7], 0x808080)
$Grid[0][7] = 3
$Grid[7][7] = 3
;--------Bishop--------
GUICtrlSetBkColor ($GuiGrid[2][7], 0x808080)
GUICtrlSetBkColor ($GuiGrid[5][7], 0x808080)
$Grid[2][7] = 4
$Grid[5][7] = 4
;--------Knight--------
GUICtrlSetBkColor ($GuiGrid[1][7], 0x808080)
GUICtrlSetBkColor ($GuiGrid[6][7], 0x808080)
$Grid[1][7] = 5
$Grid[6][7] = 5

$Console = GUICtrlCreateEdit ('', 410, 30,180, 300,$EditEx)
$Send = GUICtrlCreateEdit ('', 410, 340, 125, 50,$Edit)


GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit_', $GUI)
GUISetState ()

While 1
    Sleep (100)
WEnd
Func _Grid_Evaluate_ ()
    For $0 = 0 To 7
        For $00 = 0 To 7
            GUICtrlSetData ($GuiGrid[$0][$00], '')
        Next
    Next
    _Reset_Misc_Vars_ ()
    For $0 = 0 To 7
        For $00 = 0 To 7
            If @GUI_CtrlId = $GuiGrid[$0][$00] Then
                $IDv = $Grid[$0][$00]
                Select
                    Case $IDv = 1 ; king
                        If $0 >= 1 And $Grid[$0 - 1][$00] = 0 Then GUICtrlSetData ($GuiGrid[$0 - 1][$00], 'X')
                        If $0 <= 6 And $Grid[$0 + 1][$00] = 0 Then GUICtrlSetData ($GuiGrid[$0 + 1][$00], 'X')
                        If $00 >= 1 And $Grid[$0][$00 - 1] = 0 Then GUICtrlSetData ($GuiGrid[$0][$00 - 1], 'X')
                        If $00 <= 6 And $Grid[$0][$00 - 1] = 0 Then GUICtrlSetData ($GuiGrid[$0][$00 + 1], 'X')
                        If $0 <= 6 And $00 <= 6 And $Grid[$0 + 1][$00 + 1] = 0 Then GUICtrlSetData ($GuiGrid[$0 + 1][$00 + 1], 'X')
                        If $0 <= 6 And $00 <= 6 And $Grid[$0 + 1][$00 + 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 + 1][$00 + 1], 'X')
                        If $0 <= 6 And $00 >= 1 And $Grid[$0 + 1][$00 - 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 + 1][$00 - 1], 'X')
                        If $0 <= 6 And $00 >= 1 And $Grid[$0 + 1][$00 - 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 + 1][$00 - 1], 'X')
                        If $0 >= 1 And $00 >= 1 And $Grid[$0 - 1][$00 - 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 1][$00 - 1], 'X')
                        If $0 >= 1 And $00 >= 1 And $Grid[$0 - 1][$00 - 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 1][$00 - 1], 'X')
                        If $0 >= 1 And $00 <= 6 And $Grid[$0 - 1][$00 + 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 1][$00 + 1], 'X')
                        If $0 >= 1 And $00 <= 6 And $Grid[$0 - 1][$00 + 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 1][$00 + 1], 'X')
                    Case $IDv = 2 ; queen ALSO NEEDS THE DIAGONAL
                        For $000 = 0 To 7
                            For $0000 = 0 To 7
                                If $Grid[$0][$000] = 0 Then GUICtrlSetData ($GuiGrid[$0][$000], 'X')
                                If $Grid[$0000][$00] = 0 Then GUICtrlSetData ($GuiGrid[$0000][$00], 'X')
                            Next
                        Next
                    Case $IDv = 3 ; Rook
                        For $000 = 0 To 7
                            For $0000 = 0 To 7
                                If $Grid[$0][$000] = 0 Then GUICtrlSetData ($GuiGrid[$0][$000], 'X')
                                If $Grid[$0000][$00] = 0 Then GUICtrlSetData ($GuiGrid[$0000][$00], 'X')
                            Next
                        Next
                    Case $IDv = 4 ; Bishop THIS IS WHERE THE PROBLEM IS!!!
                        $x = 7 - $0
                        $y = 7 - $00
                        GUICtrlSetData ($GuiGrid[Int(($x^2 + $x^2)^(1/2))][Int(($y^2+$y^2)^(1/2))], 'X') ;<<================
                    Case $IDv = 5 ; Knight
                        If $0 <= 6 And $00 <= 5 And $Grid[$0 + 1][$00 + 2] = 0 Then GUICtrlSetData ($GuiGrid[$0 + 1][$00 + 2], 'X')
                        If $0 <= 5 And $00 <= 6 And $Grid[$0 + 2][$00 + 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 + 2][$00 + 1], 'X')
                        If $0 <= 5 And $00 >= 1 And $Grid[$0 + 2][$00 - 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 + 2][$00 - 1], 'X')
                        If $0 <= 6 And $00 >= 2 And $Grid[$0 + 1][$00 - 2] = 0 Then  GUICtrlSetData ($GuiGrid[$0 + 1][$00 - 2], 'X')
                        If $0 >= 1 And $00 >= 2 And $Grid[$0 - 1][$00 - 2] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 1][$00 - 2], 'X')
                        If $0 >= 2 And $00 >= 1 And $Grid[$0 - 2][$00 - 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 2][$00 - 1], 'X')
                        If $0 >= 2 And $00 <= 6 And $Grid[$0 - 2][$00 + 1] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 2][$00 + 1], 'X')
                        If $0 >= 1 And $00 <= 5 And $Grid[$0 - 1][$00 + 2] = 0 Then  GUICtrlSetData ($GuiGrid[$0 - 1][$00 + 2], 'X')
                    Case $IDv = 6 ; Pawn
                        Select
                            Case $Pawn_settings[$0][1] = 0
                                If $00 >= 2 And $Grid[$0][$00 - 1] = 0 Then GUICtrlSetData ($GuiGrid[$0][$00 - 1], 'X')
                            Case $Pawn_settings[$0][1] = 1
                                GUICtrlSetData ($GuiGrid[$0][$00 - 2], 'X')
                            Case $Pawn_settings[$0][1] = 0 And $00 = 1 And $Grid[$0][$00 - 1] = 0
                                GUICtrlSetData ($GuiGrid[$0][$00 - 1], 'X')
                        EndSelect
                EndSelect
            EndIf
        Next
    Next
    _Reset_Misc_Vars_ ()
    Return
EndFunc
Func _Reset_Misc_Vars_ ()
    $0 = 0
    $00 = 0
    $000 = 0
    $0000 = 0
    $00000 = 0
    $000000 = 0
    $0000000 = 0
    Return
EndFunc
Func _Win_Move_ ()
    $MouseXY = MouseGetPos ()
    $WinXY = WinGetPos ($GUI)
    $xOff = $MouseXY[0] - $WinXY[0]
    $yOFF = $MouseXY[1] - $WinXY[1]
    While _IsPressed ('01')
        WinMove ($GUI, '',MouseGetPos (0) - $xOff ,MouseGetPos (1) - $yOFF)
        Sleep (10)
    WEnd
    Return
EndFunc
Func _Exit_ ()
    Exit
EndFunc

its no where near complete lol could this help?

Share this post


Link to post
Share on other sites

okay... it doesn't work XD ill post my code lol

also as an afterthought.... in the HF under INT xD i found this...

As I said, I'm not that great of a programmer. I'm as good as I am though because my math algorithms. Is there any custom-rounding code on these forums that rounds from .5 and up to =1 and .49 and down to 0? Thats the only way I really see it happening because you'll always have a decimal when using the Pyth theorem. And from what I got from your script, that should work. Though I'm horrible at the arrays stuff, so I could be wrong. But from interpreting it the best I could, it looked somewhat alright (minus the Int part ><). I doubt I can be of much help from here on xD, so good luck... I'll be watching the thread though just in case a question I can answer pops up.

UnknownWarrior

Share this post


Link to post
Share on other sites

its a math problem with recursion... i'll look into it again tommorrow but i'm tired right now

so if anyone knows what i can do instead of

$x = 7 - $0

$y = 7 - $00

GUICtrlSetData ($GuiGrid[int(($x^2 + $x^2)^(1/2))][int(($y^2+$y^2)^(1/2))], 'X')

then i would like to know :) i know it has to be in a For to Loop but cannot implement what i need into Code

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

its a math problem with recursion... i'll look into it again tommorrow but i'm tired right now

so if anyone knows what i can do instead of

$x = 7 - $0

$y = 7 - $00

GUICtrlSetData ($GuiGrid[int(($x^2 + $x^2)^(1/2))][int(($y^2+$y^2)^(1/2))], 'X')

then i would like to know :) i know it has to be in a For to Loop but cannot implement what i need into Code

I haven't studied your code very carefully though I've added a possible diagonal method below. You methods look horribly complicated at the moment. I think you need just a few simple loops.

Your variable names, like $0 and $00 are revolting :)

#include <GUICONSTANTS.AU3>
 #include <WINDOWSCONSTANTS.AU3>
 #include <STATICCONSTANTS.AU3>
 #include <EDITCONSTANTS.AU3>
 #include <MISC.AU3>
 #include <WinAPI.au3>
 Opt('GUIoneventmode', 1)
 
 _Reset_Misc_Vars_()
 
 $sn = StringTrimRight(@ScriptName, 4)
 $Bk = 0xFFFFFF
 $Fc = 0x0
 $x = -40
 $ID = 0
 $IDv = 0
 $MoveStatus = 0
 $GUIStyle = BitOR($WS_POPUP, $WS_VISIBLE, $WS_SIZEBOX)
 $GUIStyleEx = BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)
 $LStyle = BitOR($SS_CENTER, $SS_CENTERIMAGE)
 $Edit = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP)
 $EditEx = BitOR($ES_READONLY, $ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP)
 
 Dim $Grid[8][8], $GuiGrid[8][8], $Pawn_settings[8][2]
 
 $GUI = GUICreate($sn, 600, 430, -1, -1, $GUIStyle, $GUIStyleEx)
 GUISetBkColor($Bk, $GUI)
 
 $lTitleBar = GUICtrlCreateLabel($sn, 20, 0, 580, 20, $LStyle)
 GUICtrlSetBkColor(-1, $Bk)
 GUICtrlSetFont(-1, 10, 400, '', 'Fixedsys')
 GUICtrlSetColor(-1, $Fc)
 GUICtrlSetOnEvent(-1, '_Win_Move_')
 
 $lExit = GUICtrlCreateLabel('x', 0, 0, 20, 20, $LStyle)
 GUICtrlSetBkColor(-1, $Bk)
 GUICtrlSetFont(-1, 10, 400, '', 'Fixedsys')
 GUICtrlSetColor(-1, $Fc)
 GUICtrlSetOnEvent(-1, '_Exit_')
 GUICtrlSetCursor(-1, 0)
 
 
 
 For $0 = 0 To 7
     $x += 50
     $y = -20
     For $00 = 0 To 7
         $y += 50
         $Grid[$0][$00] = 0
         $GuiGrid[$0][$00] = GUICtrlCreateLabel('', $x, $y, 40, 40, $LStyle)
         GUICtrlSetFont(-1, 20, 400)
         GUICtrlSetBkColor(-1, $Fc)
         GUICtrlSetCursor(-1, 0)
         GUICtrlSetColor(-1, $Bk)
         GUICtrlSetOnEvent(-1, '_Grid_Evaluate_')
         ;--------Pawn--------
         GUICtrlSetBkColor($GuiGrid[$0][6], 0x000080)
         $Grid[$0][6] = 6
         $Pawn_settings[$0][0] = $GuiGrid[$0][6]
         $Pawn_settings[$0][1] = 1 ;Still has a two block move.... 0=normal... 2-5=other pieces
     Next
 Next
 $x = 0
 $y = 0
 _Reset_Misc_Vars_()
 ;--------King--------
 GUICtrlSetBkColor($GuiGrid[4][7], 0xFF8000)
 $Grid[4][7] = 1
 ;--------Queen--------
 GUICtrlSetBkColor($GuiGrid[3][7], 0xFF80C0)
 $Grid[3][7] = 2
 ;--------Rooks--------
 GUICtrlSetBkColor($GuiGrid[0][7], 0x808080)
 GUICtrlSetBkColor($GuiGrid[7][7], 0x808080)
 $Grid[0][7] = 3
 $Grid[7][7] = 3
 ;--------Bishop--------
 GUICtrlSetBkColor($GuiGrid[2][7], 0x808080)
 GUICtrlSetBkColor($GuiGrid[5][7], 0x808080)
 $Grid[2][7] = 4
 $Grid[5][7] = 4
 ;--------Knight--------
 GUICtrlSetBkColor($GuiGrid[1][7], 0x808080)
 GUICtrlSetBkColor($GuiGrid[6][7], 0x808080)
 $Grid[1][7] = 5
 $Grid[6][7] = 5
 
 $Console = GUICtrlCreateEdit('', 410, 30, 180, 300, $EditEx)
 $Send = GUICtrlCreateEdit('', 410, 340, 125, 50, $Edit)
 
 
 GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit_', $GUI)
 GUISetState()
 
 While 1
     Sleep(100)
 WEnd
 Func _Grid_Evaluate_()
     For $0 = 0 To 7
         For $00 = 0 To 7
             GUICtrlSetData($GuiGrid[$0][$00], '')
         Next
     Next
     _Reset_Misc_Vars_()
     For $0 = 0 To 7
         For $00 = 0 To 7
             If @GUI_CtrlId = $GuiGrid[$0][$00] Then
                 $IDv = $Grid[$0][$00]
                 Select
                     Case $IDv = 1 ; king
                         For $x = $0 - 1 To $0 + 1
                             For $y = $00 - 1 To $00 + 1
                                 If $y > -1 And $y < 8 And $x < 8 And $x > -1 Then
                                     If $Grid[$x][$y] = 0 Then GUICtrlSetData($GuiGrid[$x][$y], 'X')
                                 EndIf
                             Next
                         Next
 
                         #cs too much writing for me
                             If $0 >= 1 And $Grid[$0 - 1][$00] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00], 'X')
                             If $0 <= 6 And $Grid[$0 + 1][$00] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00], 'X')
                             If $00 >= 1 And $Grid[$0][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0][$00 - 1], 'X')
                             If $00 <= 6 And $Grid[$0][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0][$00 + 1], 'X')
                             If $0 <= 6 And $00 <= 6 And $Grid[$0 + 1][$00 + 1] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00 + 1], 'X')
                             If $0 <= 6 And $00 <= 6 And $Grid[$0 + 1][$00 + 1] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00 + 1], 'X')
                             If $0 <= 6 And $00 >= 1 And $Grid[$0 + 1][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00 - 1], 'X')
                             If $0 <= 6 And $00 >= 1 And $Grid[$0 + 1][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00 - 1], 'X')
                             If $0 >= 1 And $00 >= 1 And $Grid[$0 - 1][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00 - 1], 'X')
                             If $0 >= 1 And $00 >= 1 And $Grid[$0 - 1][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00 - 1], 'X')
                             If $0 >= 1 And $00 <= 6 And $Grid[$0 - 1][$00 + 1] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00 + 1], 'X')
                             If $0 >= 1 And $00 <= 6 And $Grid[$0 - 1][$00 + 1] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00 + 1], 'X')
                         #ce
                     Case $IDv = 2 ; queen ALSO NEEDS THE DIAGONAL
                         For $000 = 0 To 7
                             For $0000 = 0 To 7
                                 If $Grid[$0][$000] = 0 Then GUICtrlSetData($GuiGrid[$0][$000], 'X')
                                 If $Grid[$0000][$00] = 0 Then GUICtrlSetData($GuiGrid[$0000][$00], 'X')
                             Next
                         Next
                     Case $IDv = 3 ; Rook
                         For $000 = 0 To 7
                             For $0000 = 0 To 7
                                 If $Grid[$0][$000] = 0 Then GUICtrlSetData($GuiGrid[$0][$000], 'X')
                                 If $Grid[$0000][$00] = 0 Then GUICtrlSetData($GuiGrid[$0000][$00], 'X')
                             Next
                         Next
                     Case $IDv = 4 ; Bishop THIS IS WHERE THE PROBLEM IS!!!
                         ConsoleWrite("bish pos = " & $0 & ', ' & $00 & @CRLF)
                         $starty = $00 ;or whatever row
                         $startx = $0;or whatever column
                         drawdiagonalsfrom($startx, $starty)
 
 
                         ; $x = 7 - $0
                         ;$y = 7 - $00
                         ;GUICtrlSetData ($GuiGrid[Int(($x^2 + $x^2)^(1/2))][Int(($y^2+$y^2)^(1/2))], 'X') ;<<================
                     Case $IDv = 5 ; Knight
                         If $0 <= 6 And $00 <= 5 And $Grid[$0 + 1][$00 + 2] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00 + 2], 'X')
                         If $0 <= 5 And $00 <= 6 And $Grid[$0 + 2][$00 + 1] = 0 Then GUICtrlSetData($GuiGrid[$0 + 2][$00 + 1], 'X')
                         If $0 <= 5 And $00 >= 1 And $Grid[$0 + 2][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0 + 2][$00 - 1], 'X')
                         If $0 <= 6 And $00 >= 2 And $Grid[$0 + 1][$00 - 2] = 0 Then GUICtrlSetData($GuiGrid[$0 + 1][$00 - 2], 'X')
                         If $0 >= 1 And $00 >= 2 And $Grid[$0 - 1][$00 - 2] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00 - 2], 'X')
                         If $0 >= 2 And $00 >= 1 And $Grid[$0 - 2][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0 - 2][$00 - 1], 'X')
                         If $0 >= 2 And $00 <= 6 And $Grid[$0 - 2][$00 + 1] = 0 Then GUICtrlSetData($GuiGrid[$0 - 2][$00 + 1], 'X')
                         If $0 >= 1 And $00 <= 5 And $Grid[$0 - 1][$00 + 2] = 0 Then GUICtrlSetData($GuiGrid[$0 - 1][$00 + 2], 'X')
                     Case $IDv = 6 ; Pawn
                         Select
                             Case $Pawn_settings[$0][1] = 0
                                 If $00 >= 2 And $Grid[$0][$00 - 1] = 0 Then GUICtrlSetData($GuiGrid[$0][$00 - 1], 'X')
                             Case $Pawn_settings[$0][1] = 1
                                 GUICtrlSetData($GuiGrid[$0][$00 - 2], 'X')
                             Case $Pawn_settings[$0][1] = 0 And $00 = 1 And $Grid[$0][$00 - 1] = 0
                                 GUICtrlSetData($GuiGrid[$0][$00 - 1], 'X')
                         EndSelect
                 EndSelect
             EndIf
         Next
     Next
     _Reset_Misc_Vars_()
     Return
 EndFunc   ;==>_Grid_Evaluate_
 Func _Reset_Misc_Vars_()
     $0 = 0
     $00 = 0
     $000 = 0
     $0000 = 0
     $00000 = 0
     $000000 = 0
     $0000000 = 0
     Return
 EndFunc   ;==>_Reset_Misc_Vars_
 Func _Win_Move_()
     $MouseXY = MouseGetPos()
     $WinXY = WinGetPos($GUI)
     $xOff = $MouseXY[0] - $WinXY[0]
     $yOFF = $MouseXY[1] - $WinXY[1]
     While _IsPressed('01')
         WinMove($GUI, '', MouseGetPos(0) - $xOff, MouseGetPos(1) - $yOFF)
         Sleep(10)
     WEnd
     Return
 EndFunc   ;==>_Win_Move_
 Func _Exit_()
     Exit
 EndFunc   ;==>_Exit_
 
 
 Func drawdiagonalsfrom($ix, $iy)
 
     For $row = 0 to 7
         $newxl = $ix - ($row - $iy)
         $newxr = $ix + ($row -$iy)
         if $newxl > -1 and $newxl < 8 and $Grid[$newxl][$row] = 0 Then GUICtrlSetData($GuiGrid[$newxl][$row], 'X')
         if $newxr > -1 and $newxr < 8 and $Grid[$newxr][$row] = 0 Then GUICtrlSetData($GuiGrid[$newxr][$row], 'X')
     Next
 
 EndFunc   ;==>drawdiagonalsfrom

EDIT: Simplified a bit

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Your variable names, like $0 and $00 are revolting

XD i use those for my misc variables.... later on i want to convert all the variable names into binary like $00100010, that will be complicated... but hey :) it works now i gotta see what you did lol thanks martin!!

Share this post


Link to post
Share on other sites

XD i use those for my misc variables.... later on i want to convert all the variable names into binary like $00100010, that will be complicated... but hey :) it works now i gotta see what you did lol thanks martin!!

See my later version which is much neater.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

lol you knocked off like 20 lines :) oh and i see what you did to the King.... i'll try and simplify my Knight also but i cannnot do it right now.

thank you man XD

Share this post


Link to post
Share on other sites

hello, i have little problem, i what to use this box, but cant find how to eleminate space behind boxes.. some body can help? thank you.

Posted Image


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

You have labels which are 30 x 30 on a pitch of 50 x 50 so therefor you have spaces between the boxes of 20.

I assume from your question that you didn't write that code and you don't understand it.

Correct me if I'm wrong though, but IMO if you can't see why you have spaces or how to change the spaces then I'm amazed you worked out how to post a question.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Martin,

i worked on this all night.. i will search the best board.. i finds this board.. i cut all what don't need.. and chenced every number but dont find how to manipulate with this spaces.. i what to do game where every box is something.... but need every box to be one big box. can u help me to find answer of question?

Thank you,

Best Regards

Tudor.


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

Martin,

i worked on this all night.. i will search the best board.. i finds this board.. i cut all what don't need.. and chenced every number but dont find how to manipulate with this spaces.. i what to do game where every box is something.... but need every box to be one big box. can u help me to find answer of question?

Thank you,

Best Regards

Tudor.

There is something wrong with your approach I think. It should be obvious that the labels are made to be 30 x 30 because that was what it gave in GuiCtrlCreateLabel. It must be obvious that a new label is made 50 away from the previous one because $x and $y are incremented by 50 each time. So if you made the labels bigger the gap would be smaller, or if you changed the distance apart then the gap would change.

Spending all night is hard to believe. Just get a piece of blank paper, draw where the first label will be and then the second. I am convinced that you can work somethjing out.

Anyway, I feel so sorry for you that I have made an example. I admit that some of the things I added I would not expect from a complete beginner but the basic idea is unchanged.

Please try to understand it; if you approach it the right way by stepping through each line and you then you can change something to get a result you want then there is hope for you.

#include <staticconstants.au3>
#include <winapi.au3>

$square = 10;how many squares on each side of the board
$side = 49;the size of the label(square)
$pitch = 50;no idea what this can be for

Dim $board[$square][$square], $gameboard[$square][$square]


$captionHt = _WinAPI_GetSystemMetrics(4)
$borderWid = _WinAPI_GetSystemMetrics(33)


$GUI = GUICreate("game board", $square * $pitch + 2 * $borderWid, $square * $pitch + 2 * $borderWid + $captionHt, -1, -1, BitOR(0x0000080, 8))

$x = -$pitch + Ceiling(($pitch - $side) / 2)

$count = 0
For $o = 0 To $square - 1
    $x += $pitch
    $y = -$side
    $count += 1;the count of columns drawn
    $Bcount = $count;the count of labels in the column
    For $oo = 0 To $square - 1
    $y += $pitch
    $board[$o][$oo] = GUICtrlCreateLabel('', $x, $y, $side, $side, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, SquareCol($Bcount))
    ;GUICtrlSetBkColor($gameboard[$o][9],0xF222FE)
    $Bcount += 1;the number of squares drawn so far
    Next
Next
GUISetState()

$cs = WinGetClientSize($GUI)
ConsoleWrite($cs[0] & ', ' & $cs[1] & @CRLF)

While GUIGetMsg() <> -3

WEnd


Func SquareCol($i)
    If Mod($i, 2) = 0 Then Return 0x00ff00;even colours

    Return 0x0000ff;odd colours

EndFunc ;==>SquareCol

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

mmm... sorry for so more questions.. but can u help me to add image on this board? :mellow:

Thank you so much.


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

mmm... sorry for so more questions.. but can u help me to add image on this board? :mellow:

Thank you so much.

All you need is a freeware chess font. Then just set the font type and size for the labels and the relavent character. No images to worry about.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

All you need is a freeware chess font. Then just set the font type and size for the labels and the relavent character. No images to worry about.

i don't understand about you talk :mellow: for first i want to put the image of the dead pixel on the part of board.. and to manipulate it to do actions on the board

like this:

post-50212-12660046266816_thumb.gif

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

i don't understand about you talk :mellow: for first i want to put the image of the dead pixel on the part of board.. and to manipulate it to do actions on the board

like this:

I thought you were making a chess board.

Have you got some code which shows your grid and a sample image of the disc?

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

here is cod:

#include <winapi.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$square = 20;how many squares on each side of the board
$side = 40;the size of the label(square)
$pitch = 41;no idea what this can be for

Dim $board[$square][$square], $gameboard[$square][$square]


$captionHt = _WinAPI_GetSystemMetrics(4)
$borderWid = _WinAPI_GetSystemMetrics(33)


$GUI = GUICreate("game board", $square * $pitch + 2 * $borderWid, $square * $pitch + 2 * $borderWid + $captionHt, -1, -1, BitOR(0x0000080, 8))



$x = -$pitch + Ceiling(($pitch - $side) / 2)

$count = 0
For $o = 0 To $square - 1
    $x += $pitch
    $y = -$side
    $count += 1;the count of columns drawn
    $Bcount = $count;the count of labels in the column
    For $oo = 0 To $square - 1
    $y += $pitch
    $board[$o][$oo] = GUICtrlCreateLabel('', $x, $y, $side, $side, BitOR($SS_CENTER, $SS_CENTERIMAGE))
    GUICtrlSetBkColor(-1, SquareCol($Bcount))
    ;GUICtrlSetBkColor($gameboard[$o][9],0xF222FE)
    $Bcount += 1;the number of squares drawn so far
    Next
Next
GUISetState()
$va = GuiCtrlCreatePic("C:\Program Files\AutoIt3\Icons\au3.ico",50, 50,50, 50)
$cs = WinGetClientSize($GUI)
ConsoleWrite($cs[0] & ', ' & $cs[1] & @CRLF)



While GUIGetMsg() <> -3

WEnd

Func SquareCol($i)
    If Mod($i, 2) = 0 Then Return 0x00ff00;even colours

    Return 0x0000ff;odd colours

EndFunc ;==>SquareCol

and in future i what to put image with actions, like this:

Posted Image Posted Image Posted Image Posted Image

but for test to use something like this:

post-50212-1266055633268_thumb.png

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0