Sign in to follow this  
Followers 0
JellyFish666

Long Process...

3 posts in this topic

I was wondering if this could be shorter some how and if it can find empty spots and set a image of my choice.

Posted ImagePosted Image

#include <GUIConstants.au3>

$GUI = GUICreate("Test", 600, 600)
;grass
_Grass(0 , 0 , 100 , 100)
_Grass(100 , 0 , 100 , 100)
_Grass(200 , 0 , 100 , 100)
_Grass(300 , 0 , 100 , 100)
_Grass(400 , 0 , 100 , 100)
_Grass(500 , 0 , 100 , 100)
;grass
;Dirt
_Dirt(0 , 100 , 100 , 100)
_Dirt(100 , 100 , 100 , 100)
_Dirt(200 , 100 , 100 , 100)
_Dirt(300 , 100 , 100 , 100)
_Dirt(400 , 100 , 100 , 100)
_Dirt(500 , 100 , 100 , 100)
_Dirt(500 , 200 , 100 , 100)
_Dirt(500 , 300 , 100 , 100)
_Dirt(500 , 400 , 100 , 100)
_Dirt(500 , 500 , 100 , 100)
_Dirt(0 , 500 , 100 , 100)
_Dirt(100 , 500 , 100 , 100)
_Dirt(200 , 500 , 100 , 100)
_Dirt(300 , 500 , 100 , 100)
_Dirt(400 , 500 , 100 , 100)
;Dirt
;Grass 
_Grass(0 , 200 , 100 , 100)
_Grass(100 , 200 , 100 , 100)
_Grass(200 , 200 , 100 , 100)
_Grass(300 , 200 , 100 , 100)
_Grass(400 , 200 , 100 , 100)
_Grass(0 , 300 , 100 , 100)
_Grass(100 , 300 , 100 , 100)
_Grass(200 , 300 , 100 , 100)
_Grass(300 , 300 , 100 , 100)
_Grass(400 , 300 , 100 , 100)
_Grass(0 , 400 , 100 , 100)
_Grass(100 , 400 , 100 , 100)
_Grass(200 , 400 , 100 , 100)
_Grass(300 , 400 , 100 , 100)
_Grass(400 , 400 , 100 , 100)
;grass
GUISetState(@SW_SHOW)
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _Dirt($DirtX , $DirtY , $DirtW , $DirtH)
    $Dirt = GUICtrlCreatePic("C:\Documents and Settings\XPPRESP3\Desktop\Turret Defense\dirt.bmp", $DirtX, $DirtY , $DirtY , $DirtH)
EndFunc

Func _Grass($GrassX , $GrassY , $GrassW , $GrassH)
    $Grass = GUICtrlCreatePic("C:\Documents and Settings\XPPRESP3\Desktop\Turret Defense\grass.bmp", $GrassX, $GrassY, $GrassW, $GrassH)
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I was wondering if this could be shorter some how and if it can find empty spots and set a image of my choice.

This be another way.

#include <GUIConstants.au3>
Global $array[6][6] = [[1, 0, 1, 1, 1, 0],[1, 0, 1, 1, 1, 0],[1, 0, 1, 0, 0, 1], _
        [1, 0, 0, 0, 0, 0],[1, 0, 1, 1, 1, 0],[1, 0, 1, 0, 0, 1]]
Global $hpic[36], $increment = 0
Global $pictures[6] = ["C:\Documents and Settings\mc.MAL\Desktop\grassuu8.bmp", _
        "C:\Documents and Settings\mc.MAL\Desktop\dirtta2.bmp"]
Local $message

$GUI = GUICreate("Test", 600, 600)

For $x = 0 To 5
    For $y = 0 To 5
        $hpic[$increment] = GUICtrlCreatePic($pictures[$array[$x][$y]], $x * 100, $y * 100, 100, 100)
        GUICtrlSetTip($hpic[$increment], "Position: $array[" & $x & "][" & $y & "]   $hPic[" _
                 & $array[$x][$y] & "]" & @CRLF & "Pic = " & $pictures[$array[$x][$y]])
        $increment += 1
    Next
Next
For $x = 0 To 1
    $message &= "Enter " & $x & "  for " & $pictures[$x] & @CRLF
Next

GUISetState(@SW_SHOW)
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_SECONDARYUP
            $id = _ControlGetHovered()
            $increment = InputBox("title", $message, "", "", 400, 150)
            If $increment <> "" Then GUICtrlSetImage($id, $pictures[$increment])
            
            ;MsgBox(0,"",$increment)
    EndSwitch
WEnd

Func _ControlGetHovered()
    Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", _
            "long", MouseGetPos(0), _
            "long", MouseGetPos(1))
    $iRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $iRet[0])
    Return $iRet[0]
EndFunc   ;==>_ControlGetHovered

The variables in the 6x6 $array represents the index of the $pictures array.

There are only two images in the $pictures array, $pictures[0] and $pictures[1]. Therefore, 0 and 1 are the only valid data that can be entered in the $array array.

Good luck, have fun.

Edit: Added change image routine.

Edited by Malkey

Share this post


Link to post
Share on other sites

This be another way.

#include <GUIConstants.au3>
Global $array[6][6] = [[1, 0, 1, 1, 1, 0],[1, 0, 1, 1, 1, 0],[1, 0, 1, 0, 0, 1], _
        [1, 0, 0, 0, 0, 0],[1, 0, 1, 1, 1, 0],[1, 0, 1, 0, 0, 1]]
Global $hpic[36], $increment = 0
Global $pictures[6] = ["C:\Documents and Settings\mc.MAL\Desktop\grassuu8.bmp", _
        "C:\Documents and Settings\mc.MAL\Desktop\dirtta2.bmp"]
Local $message

$GUI = GUICreate("Test", 600, 600)

For $x = 0 To 5
    For $y = 0 To 5
        $hpic[$increment] = GUICtrlCreatePic($pictures[$array[$x][$y]], $x * 100, $y * 100, 100, 100)
        GUICtrlSetTip($hpic[$increment], "Position: $array[" & $x & "][" & $y & "]   $hPic[" _
                 & $array[$x][$y] & "]" & @CRLF & "Pic = " & $pictures[$array[$x][$y]])
        $increment += 1
    Next
Next
For $x = 0 To 1
    $message &= "Enter " & $x & "  for " & $pictures[$x] & @CRLF
Next

GUISetState(@SW_SHOW)
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_SECONDARYUP
            $id = _ControlGetHovered()
            $increment = InputBox("title", $message, "", "", 400, 150)
            If $increment <> "" Then GUICtrlSetImage($id, $pictures[$increment])
            
            ;MsgBox(0,"",$increment)
    EndSwitch
WEnd

Func _ControlGetHovered()
    Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", _
            "long", MouseGetPos(0), _
            "long", MouseGetPos(1))
    $iRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $iRet[0])
    Return $iRet[0]
EndFunc   ;==>_ControlGetHovered

The variables in the 6x6 $array represents the index of the $pictures array.

There are only two images in the $pictures array, $pictures[0] and $pictures[1]. Therefore, 0 and 1 are the only valid data that can be entered in the $array array.

Good luck, have fun.

Edit: Added change image routine.

Thanks, but I changed the picture paths and can't seem to get this script to work for some reason.

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