Sign in to follow this  
Followers 0
Topher

Plastic Sliding Squares Puzzle v1.01

17 posts in this topic

#1 ·  Posted (edited)

Remember when you were a kid (if you are as ancient as I) and there were these cheap plastic puzzles of sliding squares that you were suppose to get in the right order?

Well this is that ;)

Enjoy

Posted Image

Version 1.01

Cosmetic and Platform changes

Plastic Sliding Puzzle.au3

Edited by Topher
2 people like this

[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

Share this post


Link to post
Share on other sites



Wow, great game! Reminds me when I was young too.

Great implementation! Took me 168 moves - I know I'm a bit rusty ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you.

When my score passes 16 or so I've so badly messed it up that I never get it. So I am impressed.


[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

Share this post


Link to post
Share on other sites

As I recall there were only <edit>15</edit> slats in the square puzzles I ever solved Posted Image

In my mind it was so clearly a 5x5 grid, but in looking for a picture to turn into an icon they were all as you said 4x4.


[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

Share this post


Link to post
Share on other sites

I remember that I had two of these puzzles. One was 4x4 and the other was 4x6 or even 4x7.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Nice!

Eukalyptus made some similar with pictures.

You need a picture with 440x440 pixels.

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Global $iTile = 0, $iSize, $hLabel[5][5], $aField[5][5][3]
Global $aFiles = _FileListToArray(@ScriptDir, "*.jpg", 1)
_ArrayCombine($aFiles, _FileListToArray(@ScriptDir, "*.bmp", 1))
_ArrayCombine($aFiles, _FileListToArray(@ScriptDir, "*.tif", 1))
_ArrayCombine($aFiles, _FileListToArray(@ScriptDir, "*.gif", 1))
_ArrayCombine($aFiles, _FileListToArray(@ScriptDir, "*.png", 1))
If Not IsArray($aFiles) Or $aFiles[0] < 1 Then
    MsgBox(0, "Error", "No pics found")
    Exit
EndIf
_GDIPlus_Startup()
Global $hImage, $iWidth, $iHeight
Global $hPenWhite = _GDIPlus_PenCreate(0x44FFFFFF, 2)
Global $hPenBlack = _GDIPlus_PenCreate(0x44000000, 2)
Global $hBrushBK = _GDIPlus_BrushCreateSolid(0xFF6C99B4)
Global $hGui = GUICreate("SchiebePuzzle", 452, 500)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetOnEvent($GUI_EVENT_RESTORE, "_ReDraw")
GUISetBkColor(0x6C99B4)
GUICtrlCreateLabel("", 4, 4, 444, 444)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0x558097)
GUICtrlCreateLabel("", 6, 6, 442, 442)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0x88B8D8)
GUICtrlCreateLabel("", 6, 6, 440, 440)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0x6C99B4)
GUICtrlCreateLabel("Anzahl der Felder:", 10, 468, 90, 20)
Global $hInput = GUICtrlCreateInput(3, 100, 465, 30, 20, $ES_READONLY)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 5, 2)
GUICtrlSetOnEvent(-1, "_SetTile")
GUICtrlCreateButton("Mischen", 160, 465, 80, 20)
GUICtrlSetOnEvent(-1, "_Randomize")
GUICtrlCreateButton("Neues Bild", 260, 465, 80, 20)
GUICtrlSetOnEvent(-1, "_LoadRandomImage1")
GUICtrlCreateButton("Beenden", 360, 465, 80, 20)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
GUIRegisterMsg($WM_PAINT, '_Redraw')
_LoadRandomImage()
_SetTile()

While 1
    Sleep(100)
WEnd

Func _MoveField()
    Local $iX, $iY, $iNX, $iNY, $iDir
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            If $hLabel[$i][$j] = @GUI_CtrlId Then
                $iX = $i
                $iY = $j
                ExitLoop 2
            EndIf
        Next
    Next
    If $aField[$iX][$iY][2] <> 2 Then Return
    $iNX = $iX
    $iNY = $iY
    Select
        Case $iX > 0 And $aField[$iX - 1][$iY][2] = 0
            $iNX = $iX - 1
            $iDir = 1
        Case $iX < $iTile - 1 And $aField[$iX + 1][$iY][2] = 0
            $iNX = $iX + 1
            $iDir = 2
        Case $iY > 0 And $aField[$iX][$iY - 1][2] = 0
            $iNY = $iY - 1
            $iDir = 3
        Case $iY < $iTile - 1 And $aField[$iX][$iY + 1][2] = 0
            $iNY = $iY + 1
            $iDir = 4
    EndSelect
    For $i = 0 To $iSize Step 5
        Switch $iDir
            Case 1
                _DrawField($iX, $iY, -$i, 0)
            Case 2
                _DrawField($iX, $iY, $i, 0)
            Case 3
                _DrawField($iX, $iY, 0, -$i)
            Case 4
                _DrawField($iX, $iY, 0, $i)
        EndSwitch
        Sleep(10)
    Next
    $aField[$iNX][$iNY][0] = $aField[$iX][$iY][0]
    $aField[$iNX][$iNY][1] = $aField[$iX][$iY][1]
    $aField[$iNX][$iNY][2] = $aField[$iX][$iY][2]
    $aField[$iX][$iY][2] = False
    GUICtrlSetBkColor($hLabel[$iX][$iY], 0x6C99B4)
    _DrawField($iNX, $iNY)
    _SetFreeField()
EndFunc   ;==>_MoveField
Func _LoadRandomImage1()
    _WinAPI_RedrawWindow($hGui)
    _LoadRandomImage()
    _ReDraw()
EndFunc   ;==>_LoadRandomImage1

Func _LoadRandomImage($Orig = False)
    Local $iRandom = Random(1, $aFiles[0], 1)
    If $iRandom = 0 Or $aFiles[0] = 1 Then $iRandom = 1
    If $Orig = False Then $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "" & $aFiles[$iRandom])
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            GUICtrlSetCursor($hLabel[$i][$j], 2)
            $aField[$i][$j][0] = $i * $iSize
            $aField[$i][$j][1] = $j * $iSize
            $aField[$i][$j][2] = 1
        Next
    Next
    $aField[0][0][2] = 0
    $aField[1][0][2] = 2
    $aField[0][1][2] = 2
    GUICtrlSetCursor($hLabel[1][0], 0)
    GUICtrlSetCursor($hLabel[0][1], 0)
EndFunc   ;==>_LoadRandomImage
Func _Randomize()
    GUIRegisterMsg($WM_PAINT, '')
    Local $iX = 0, $iY = 0, $iNX, $iNY, $iDir
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            If $aField[$i][$j][2] = 0 Then
                $iX = $i
                $iY = $j
                ExitLoop 2
            EndIf
        Next
    Next
    For $c = 1 To 500
        Do
            $iNX = $iX
            $iNY = $iY
            $iDir = Random(1, 4, 1)
            Select
                Case $iDir = 2 And $iX > 0
                    $iNX = $iX - 1
                Case $iDir = 1 And $iX < $iTile - 1
                    $iNX = $iX + 1
                Case $iDir = 4 And $iY > 0
                    $iNY = $iY - 1
                Case $iDir = 3 And $iY < $iTile - 1
                    $iNY = $iY + 1
            EndSelect
        Until $iX <> $iNX Or $iY <> $iNY
        $aField[$iX][$iY][0] = $aField[$iNX][$iNY][0]
        $aField[$iX][$iY][1] = $aField[$iNX][$iNY][1]
        $aField[$iX][$iY][2] = $aField[$iNX][$iNY][2]
        $aField[$iNX][$iNY][2] = False
        GUICtrlSetBkColor($hLabel[$iNX][$iNY], 0x6C99B4)
        _DrawField($iX, $iY)
        $iX = $iNX
        $iY = $iNY
    Next
    _ReDraw()
    _SetFreeField()
    GUIRegisterMsg($WM_PAINT, '_Redraw')
EndFunc   ;==>_Randomize
Func _SetFreeField()
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            GUICtrlSetCursor($hLabel[$i][$j], 2)
            If $aField[$i][$j][2] <> 0 Then $aField[$i][$j][2] = 1
        Next
    Next
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            If $aField[$i][$j][2] = False Then
                If $i > 0 Then
                    GUICtrlSetCursor($hLabel[$i - 1][$j], 0)
                    $aField[$i - 1][$j][2] = 2
                EndIf
                If $i < $iTile - 1 Then
                    GUICtrlSetCursor($hLabel[$i + 1][$j], 0)
                    $aField[$i + 1][$j][2] = 2
                EndIf
                If $j > 0 Then
                    GUICtrlSetCursor($hLabel[$i][$j - 1], 0)
                    $aField[$i][$j - 1][2] = 2
                EndIf
                If $j < $iTile - 1 Then
                    GUICtrlSetCursor($hLabel[$i][$j + 1], 0)
                    $aField[$i][$j + 1][2] = 2
                EndIf
            EndIf
        Next
    Next
EndFunc   ;==>_SetFreeField

Func _DrawField($x, $y, $iOX = 0, $iOY = 0)
    If $aField[$x][$y][2] = False Then Return
    Local $iX = $aField[$x][$y][0]
    Local $iY = $aField[$x][$y][1]
    Switch True
        Case $iOX > 0
            _GDIPlus_GraphicsFillRect($hGraphics, 6 + $x * $iSize, 6 + $y * $iSize, $iOX, $iSize, $hBrushBK)
        Case $iOX < 0
            _GDIPlus_GraphicsFillRect($hGraphics, 6 + $x * $iSize + $iSize + $iOX, 6 + $y * $iSize, -$iOX, $iSize, $hBrushBK)
        Case $iOY > 0
            _GDIPlus_GraphicsFillRect($hGraphics, 6 + $x * $iSize, 6 + $y * $iSize, $iSize, $iOY, $hBrushBK)
        Case $iOY < 0
            _GDIPlus_GraphicsFillRect($hGraphics, 6 + $x * $iSize, 6 + $y * $iSize + $iSize + $iOY, $iSize, -$iOY, $hBrushBK)
    EndSwitch
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, $iX, $iY, $iSize, $iSize, 6 + $x * $iSize + $iOX, 6 + $y * $iSize + $iOY, $iSize, $iSize)
    _GDIPlus_GraphicsDrawLine($hGraphics, 6 + $x * $iSize + $iOX, 7 + $y * $iSize + $iOY, $iSize + 6 + $x * $iSize + $iOX, 7 + $y * $iSize + $iOY, $hPenWhite)
    _GDIPlus_GraphicsDrawLine($hGraphics, 7 + $x * $iSize + $iOX, 6 + $y * $iSize + $iOY, 7 + $x * $iSize + $iOX, $iSize + 6 + $y * $iSize + $iOY, $hPenWhite)
    _GDIPlus_GraphicsDrawLine($hGraphics, 6 + $x * $iSize + $iOX, $iSize + 5 + $y * $iSize + $iOY, $iSize + 6 + $x * $iSize + $iOX, $iSize + 5 + $y * $iSize + $iOY, $hPenBlack)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iSize + 5 + $x * $iSize + $iOX, 6 + $y * $iSize + $iOY, $iSize + 5 + $x * $iSize + $iOX, $iSize + 6 + $y * $iSize + $iOY, $hPenBlack)
EndFunc   ;==>_DrawField

Func _SetTile()
    If $iTile = GUICtrlRead($hInput) Then Return
    GUIRegisterMsg($WM_PAINT, '')
    For $i = 0 To 4
        For $j = 0 To 4
            GUICtrlDelete($hLabel[$i][$j])
        Next
    Next
    $iTile = GUICtrlRead($hInput)
    $iSize = Round(440 / $iTile)
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            $hLabel[$i][$j] = GUICtrlCreateLabel("", 6 + $i * $iSize, 6 + $j * $iSize, $iSize, $iSize)
            GUICtrlSetCursor(-1, 2)
            GUICtrlSetOnEvent(-1, "_MoveField")
        Next
    Next
    _LoadRandomImage(True)
    _ReDraw()
    GUIRegisterMsg($WM_PAINT, '_Redraw')
EndFunc   ;==>_SetTile

Func _ReDraw()
    For $i = 0 To $iTile - 1
        For $j = 0 To $iTile - 1
            _DrawField($i, $j)
        Next
    Next
EndFunc   ;==>_ReDraw

Func _ArrayCombine(ByRef $aArray, $aNew)
    If Not IsArray($aNew) Then Return
    Local $iArray = UBound($aArray) - 1, $iNew = UBound($aNew) - 1
    Local $aReturn[$iArray + $iNew + 1]
    For $i = 1 To $iArray
        $aReturn[$i] = $aArray[$i]
    Next
    For $i = 1 To $iNew
        $aReturn[$i + $iArray] = $aNew[$i]
    Next
    $aReturn[0] = $iArray + $iNew
    $aArray = $aReturn
EndFunc   ;==>_ArrayCombine
Func _Exit()
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

On my XP, I believe the $BS_BITMAP in the GUICtrlCreateButton function was hiding all the numbers on the buttons.

I continued to play with your script and swap these to commands around, Scramble() and GUISetState(): and,

added colour.

Topher, good job.

#NoTrayIcon
#cs ----------------------------------------------------------------------------
    AutoIt Version: 3.3.6.1
    Author:   Garth Bigelow
    email:     garthbigelow@gmail.com
    Script Function: Sliding Squiare Puzzle
#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <WindowsConstants.au3>

Const $version = "Plastic Sliding Squares Puzzle v1.00"

; Size of the Grid - 1
; 2 to 11
$Size = 4
;
; Speed of Sliding Movement
; 0 to ridiculously slow
$Speed = 0
;
; Number of potential moves
; needs to be rather larger as movement back and forth happens more often than you would think
; the smaller the grid the larger complexity needs to be
; the greater complexity the more challenging the puzzle
$Complexity = 30
;
; Whether empty square is the last number or not
; 0 for not
$Advanced = 0
;
; Disregard the Ini file and use the values above or not
$Ignore = False

If FileExists("PSSP.ini") = 0 Then
    IniWrite("PSSP.ini", "Config", "Grid Size", 5)
    IniWrite("PSSP.ini", "Config", "Speed", 10)
    IniWrite("PSSP.ini", "Config", "Complexity", 30)
    IniWrite("PSSP.ini", "Config", "Adanced", 0)
EndIf
If Not $Ignore Then
    $Size = IniRead("PSSP.ini", "Config", "Grid Size", 5) - 1
    $Speed = IniRead("PSSP.ini", "Config", "Speed", 10)
    $Complexity = IniRead("PSSP.ini", "Config", "Complexity", 30)
    $Advanced = IniRead("PSSP.ini", "Config", "Adanced", 0)
EndIf

Dim $hBoard[($Size + 1)][($Size + 1)]

Global $GoX, $GoY, $MoveCount = 0, $MenuSpace = 0

$hGUI = GUICreate($version, 68 * ($Size + 1) + 3, 68 * ($Size + 1) + $MenuSpace, -1, -1, -1, $WS_EX_COMPOSITED)
GUISetBkColor(0xAA4444)
If $Advanced = 0 Then
    $EmptySquare = ($Size + 1) * ($Size + 1)
Else
    $EmptySquare = Rand(($Size + 1) * ($Size + 1))
EndIf
For $x = 0 To $Size
    For $y = 0 To $Size
        $label = ($y) * ($Size + 1) + ($x + 1)

        $hBoard[$x][$y] = GUICtrlCreateButton($label, $x * 68 + 3, $y * 68 + 3 + $MenuSpace, 62, 62, $BS_FLAT)
        ;$hBoard[$x][$y] = GUICtrlCreateButton(String($label), $x * 68 + 3, $y * 68 + 3 + $MenuSpace, 62, 62, BitOR($BS_BITMAP, $BS_FLAT))
        GUICtrlSetBkColor(-1, Number("0x" & Hex(Random(0x80, 0xff, 1), 2) & Hex(Random(0x80, 0xff, 1), 2) & Hex(Random(0x80, 0xff, 1), 2)))

        If $EmptySquare = $label Then GUICtrlSetState($hBoard[$x][$y], $GUI_HIDE)
    Next
Next

Scramble()
GUISetState()

$MoveCount = 0

While True
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        GUIDelete()
        Exit
    EndIf
    ProcessClick()
    If Over() Then
        NumToCoord($EmptySquare)
        GUICtrlSetState($hBoard[$GoX][$GoY], $GUI_SHOW)
        MsgBox(48, "Puzzle Completed", "You completed the puzzle in " & $MoveCount & " moves.")
        Exit
    EndIf
WEnd

Func ProcessClick()

    For $px = 0 To $Size
        For $py = 0 To $Size
            If $msg = $hBoard[$px][$py] Then
                If IsValidClick($px, $py) Then
                    Slide($px, $py)
                    Return
                EndIf
                Return
            EndIf
        Next
    Next
    Sleep(10)

EndFunc   ;==>ProcessClick

Func Scramble()

    $holdSpeed = $Speed
    $Speed = 0
    $a = $Complexity
    While $a > 0
        $x = Rand($Size)
        $y = Rand($Size)
        If IsValidClick($x, $y) Then
            Slide($x, $y)
            $a -= 1
        EndIf
    WEnd
    $Speed = $holdSpeed

EndFunc   ;==>Scramble

Func Slide($x, $y)

    NumToCoord($EmptySquare)
    If $x > $GoX Then SlideLeft($x, $y)
    If $x < $GoX Then SlideRight($x, $y)
    If $y > $GoY Then SlideUp($x, $y)
    If $y < $GoY Then SlideDown($x, $y)
    $MoveCount += 1

EndFunc   ;==>Slide

Func SlideDown($x, $y)

    NumToCoord($EmptySquare)
    For $line = 1 To 68
        For $b = $y To $GoY
            GUICtrlSetPos($hBoard[$x][$b], $x * 68 + 3, ($b * 68 + 3 + $MenuSpace) + $line)
        Next
        Sleep($Speed)
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoY - 1 To $y Step -1
        $hBoard[$x][$b + 1] = $hBoard[$x][$b]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc   ;==>SlideDown

Func SlideLeft($x, $y)

    NumToCoord($EmptySquare)
    For $line = 1 To 68
        For $b = $GoX To $x
            GUICtrlSetPos($hBoard[$b][$y], ($b * 68 + 3) - $line, ($y * 68 + 3 + $MenuSpace))
        Next
        Sleep($Speed)
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoX + 1 To $x
        $hBoard[$b - 1][$y] = $hBoard[$b][$y]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc   ;==>SlideLeft

Func SlideRight($x, $y)

    NumToCoord($EmptySquare)
    For $line = 1 To 68
        For $b = $x To $GoX - 1
            GUICtrlSetPos($hBoard[$b][$y], ($b * 68 + 3) + $line, ($y * 68 + 3 + $MenuSpace))
        Next
        Sleep($Speed)
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoX - 1 To $x Step -1
        $hBoard[$b + 1][$y] = $hBoard[$b][$y]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc   ;==>SlideRight

Func SlideUp($x, $y) ; checked

    NumToCoord($EmptySquare)
    For $line = 1 To 68
        For $b = $GoY To $y
            GUICtrlSetPos($hBoard[$x][$b], $x * 68 + 3, ($b * 68 + 3 + $MenuSpace) - $line)
        Next
        Sleep($Speed)
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoY + 1 To $y
        $hBoard[$x][$b - 1] = $hBoard[$x][$b]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc   ;==>SlideUp

Func IsValidClick($x, $y)

    NumToCoord($EmptySquare)
    $EmptyX = $GoX
    $EmptyY = $GoY
    NumToCoord(GUICtrlRead($hBoard[$x][$y]))
    If $EmptyX = $GoX Or $EmptyY = $GoY Then Return 1
    Return 0

EndFunc   ;==>IsValidClick

Func NumToCoord($Num)

    For $x = 0 To $Size
        For $y = 0 To $Size
            $lnum = GUICtrlRead($hBoard[$x][$y])
            If $Num = $lnum Then
                $GoX = $x
                $GoY = $y
                ExitLoop 2
            EndIf
        Next
    Next

EndFunc   ;==>NumToCoord

Func Over()

    For $x = 0 To $Size
        For $y = 0 To $Size
            If ($y) * ($Size + 1) + ($x + 1) <> GUICtrlRead($hBoard[$x][$y]) Then Return 0
        Next
    Next
    Return 1

EndFunc   ;==>Over


;
; bend random() function to my needs
;
Func Rand($pMax)

    Return Random(0, $pMax, 1)

EndFunc   ;==>Rand

Share this post


Link to post
Share on other sites

This is cool good job ;).

Share this post


Link to post
Share on other sites

On my XP, I believe the $BS_BITMAP in the GUICtrlCreateButton function was hiding all the numbers on the buttons.

I continued to play with your script and swap these to commands around, Scramble() and GUISetState(): and,

added colour.

Thanks.

I played with it a bit, opting for the black and red digits of the most common versions of the physical puzzle.

Thanks for the knowledge on $BS_BITMAP


[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

Share this post


Link to post
Share on other sites

It reminds me my childhood ! ;)

Nicely done !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Version 1.01 released.

Cosmetic and Platform changes


[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

Share this post


Link to post
Share on other sites

Great! Looks even better - more like the one I had when I was young (so long ago ;)).

The new version seems to be even faster: I only needed 47 moves.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Removed slide animation. Took too long.

If you have time, see if you could add frame rate independent animations.

Func SlideDown($x, $y)

    NumToCoord($EmptySquare)

    For $b = $y To $GoY
        GUICtrlSetPos($hBoard[$x][$b], $x * 68 + 3, ($b * 68 + 3 + $MenuSpace) + 68)
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoY - 1 To $y Step - 1
        $hBoard[$x][$b+1] = $hBoard[$x][$b]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc

Func SlideLeft($x, $y)

    NumToCoord($EmptySquare)

    For $b = $GoX To $x
        GUICtrlSetPos($hBoard[$b][$y], ($b * 68 + 3) - 68, ($y * 68 + 3 + $MenuSpace))
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoX + 1 To $x
        $hBoard[$b-1][$y] = $hBoard[$b][$y]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc

Func SlideRight($x, $y)

    NumToCoord($EmptySquare)

    For $b = $x To $GoX - 1
        GUICtrlSetPos($hBoard[$b][$y], ($b * 68 + 3) + 68, ($y * 68 + 3 + $MenuSpace))
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoX - 1 To $x Step - 1
        $hBoard[$b+1][$y] = $hBoard[$b][$y]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc

Func SlideUp($x, $y) ; checked

    NumToCoord($EmptySquare)

    For $b = $GoY To $y
        GUICtrlSetPos($hBoard[$x][$b], $x * 68 + 3, ($b * 68 + 3 + $MenuSpace) - 68)
    Next
    $holdHandle = $hBoard[$GoX][$GoY]
    For $b = $GoY + 1 To $y
        $hBoard[$x][$b-1] = $hBoard[$x][$b]
    Next
    $hBoard[$x][$y] = $holdHandle

EndFunc
Edited by Manadar

Share this post


Link to post
Share on other sites

Now is better!!!

The credit goes to Malkey.


[left][hr]
$mood = "whimsy"
$mode = "confused"
$randomChaos = True
Do
Something()
Until $Tired
[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left]

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

  • Similar Content

    • Slaventii_M
      By Slaventii_M
      Hi everybody!
      I've been studying Autoit not so long ago and today I want to share my game with you.
      Please check it out and tell me your opinion.
      Files in the archive:
      BG.jpg
      Mole.png
      Mole_Dead.png
      Shoot.wav
      Cursor.cur
      Game_Icon.iso
      Mole Shooter.au3
      Mole Shooter.exe
      Screenshots:
      Screenshot 1
      Screanshot 2
      Screanshot 3
      Files:
      Mole Shooter.rar
      Created and tested:
      Windows XP SP3 Game Edition (x86)
      Autoit Version: 3.3.10.2
    • seangriffin
      By seangriffin
      This is my first release of Box2D for AutoIT.  A very fun and exciting UDF to be bringing to you all.  For those who don't know, Box2D is a physics engine (see http://box2d.org/).  It simulates physical systems using rigid bodies and collision detection.  It is arguably the most prevalent physics engine in existence, within popular physics-based games like Angry Birds using it, and is also at the core of other advanced physics engines such as Unity.
      For a quick demonstration of this UDF in action see the following YouTube video ->  https://youtu.be/h5QH1O63Wik
      Or play "Angry Nerds", the demo game, for yourself.  Visit the EXAMPLES section below.
      Box2D is purely a mathematical engine.  It can model physics numerically.  This in itself is quite interesting, however it really shines when applied to a good graphics engine.  Recently I posted my SFML UDF over here ...
      After benchmarking several popular graphics engines (i.e. GDI+, Direct2D, Irrlicht and SFML) with this Box2D UDF I've selected SFML as my favourite, and the engine that I believe performs the best (fastest) with a rich set of functions appropriate for any physics engine.  With Box2D married with SFML, and running on AutoIT, the results are stunning.
      A HUGE THANK-YOU to jRowe and linus (for the Irrlicht UDF) and UEZ for his post on GDI+ loading screens and trancexx and Eukalyptus for their work on Direct2D.  Without their talents I would not have been able to reach this point on my own.
      The Box2D library is available for C++.  Way back in 2010 it was ported to Pure C by "Paril" and made available on Google Code and known as "Box2C".  Google Code has since been shut down but the but the archive of Box2C still exists to this day here -> https://code.google.com/archive/p/box2c.  This is the library which I have ported to AutoIT in this UDF.
      SFML I am also porting to AutoIT under a separate UDF, as linked above.
      Building this UDF has been a dream come true.  I've been fascinated by physics-based games as far back as the golden age of gaming in the 80's, with thrust style games like Asteroids and platformers like Donkey Kong.  I admired game developers like Jeremy Smith who created what may have been the first true game physics engines for the home computers.  I was astonished by their talents in games like Thrust and Exile for the C64.  Over the years I've attempted to mimic at least some of their success in my own games but alas I can not match their skills.  Now much older automation tools have become my game.  I use them almost every day, AutoIT included.  I've dabbled in other languages for physics game development, like Scratch and Unity, but sadly I had wondered why AutoIT, with all it's glorious capabilities and rapid scripting features, didn't have such a feature.  Hence this UDF.
      This UDF demands a big time investment, and I am time poor, but I have a keen interest in the topic and will do my best to continue it's development.  I am only a hobbyist game developer and welcome comments and suggestions from those far smarter than I on this topic.
      REQUIREMENTS:
      AutoIt3 3.2 or higher LIST OF FUNCTIONS (in progress):
      I've split this UDF into two halves.  "Box2C.au3" is a UDF specifically for Box2C, the C API for Box2D.  It provides the mathematics behind the engine.  Additionally I'm providing "Box2CEx.au3" as an Extension that provides the graphics and gaming functions for Box2D.
      Within the core "Box2C.au3" UDF:
      _Box2C_Startup _Box2C_Shutdown _Box2C_b2Vec2_Constructor _Box2C_b2Vec2_Length _Box2C_b2Vec2_Distance _Box2C_b2World_Constructor _Box2C_b2World_CreateBody _Box2C_b2World_DestroyBody _Box2C_b2World_CreateFixture _Box2C_b2World_CreateFixtureFromShape _Box2C_b2World_Step _Box2C_b2BoxShape_Constructor _Box2C_b2CircleShape_Constructor _Box2C_b2PolygonShape_Constructor _Box2C_b2PolygonShape_Set _Box2C_b2PolygonShape_CrossProductVectorScalar _Box2C_b2PolygonShape_CrossProductVectorVector _Box2C_b2PolygonShape_Normalize _Box2C_b2PolygonShape_ComputeCentroid _Box2C_b2BodyDef_Constructor _Box2C_b2Body_DestroyFixture _Box2C_b2Body_GetPosition _Box2C_b2Body_SetPosition _Box2C_b2Body_GetAngle _Box2C_b2Body_SetAngle _Box2C_b2Body_SetAwake _Box2C_b2Body_SetTransform _Box2C_b2Body_GetLinearVelocity _Box2C_b2Body_SetLinearVelocity _Box2C_b2Body_GetAngularVelocity _Box2C_b2Body_SetAngularVelocity _Box2C_b2Body_ApplyForce _Box2C_b2Body_ApplyForceAtBody _Box2C_b2Body_ApplyDirectionalForceAtBody _Box2C_b2Body_ApplyTorque _Box2C_b2Fixture_GetShape _Box2C_b2Fixture_GetDensity _Box2C_b2Fixture_SetDensity _Box2C_b2Fixture_GetRestitution _Box2C_b2Fixture_SetRestitution _Box2C_b2Fixture_GetFriction _Box2C_b2Fixture_SetFriction _Box2C_b2Fixture_SetSensor Within y "Box2CEx.au3" extension:
      x_metres_to_gui_x y_metres_to_gui_y metres_to_pixels atan2 radians_to_degrees degrees_to_radians _Box2C_Setup_SFML _Box2C_b2Vec2_GetGUIPosition _Box2C_b2World_Setup _Box2C_b2World_GDIPlusSetup _Box2C_b2World_SetPixelsPerMetre _Box2C_b2World_SetGUIArea _Box2C_b2World_GetGUIArea _Box2C_b2World_GetGUIAreaCenter _Box2C_b2World_Create _Box2C_b2World_Step_Ex _Box2C_b2World_StartAnimation _Box2C_b2World_Animate_SFML _Box2C_b2World_Animate_GDIPlus _Box2C_b2World_WaitForAnimateEnd _Box2C_b2ShapeArray_AddItem_SFML _Box2C_b2ShapeArray_SetItem_SFML _Box2C_b2ShapeArray_GetItemImagePath_SFML _Box2C_b2PolygonShape_ArrayAdd_Irrlicht _Box2C_b2PolygonShape_ArrayAdd_GDIPlus _Box2C_b2BodyDefArray_AddItem _Box2C_b2FixtureArray_SetItemSensor _Box2C_b2FixtureArray_GetItemDensity _Box2C_b2FixtureArray_SetItemDensity _Box2C_b2FixtureArray_GetItemRestitution _Box2C_b2FixtureArray_SetItemRestitution _Box2C_b2FixtureArray_GetItemFriction _Box2C_b2FixtureArray_SetItemFriction _Box2C_b2BodyArray_AddItem_SFML _Box2C_b2Body_ArrayAdd_Irrlicht _Box2C_b2Body_ArrayAdd_GDIPlus _Box2C_b2BodyArray_GetItemCount _Box2C_b2BodyArray_GetItemPosition _Box2C_b2BodyArray_SetItemPosition _Box2C_b2BodyArray_GetItemAngle _Box2C_b2BodyArray_SetItemAngle _Box2C_b2BodyArray_GetItemLinearVelocity _Box2C_b2BodyArray_SetItemActive _Box2C_b2BodyArray_SetItemAwake _Box2C_b2BodyArray_SetItemImage_SFML _Box2C_b2BodyArray_SetItemDraw _Box2C_b2BodyArray_ApplyItemForceAtBody _Box2C_b2BodyArray_ApplyItemDirectionalForceAtBody _Box2C_b2BodyArray_Transform_SFML _Box2C_b2Body_Transform_GDIPlus _Box2C_b2BodyArray_Draw_SFML _Box2C_b2Body_ArrayDrawDisplay_SFML _Box2C_b2Body_Destroy _Box2C_b2Body_Destroy_SFML _Box2C_b2Body_Rotate_GDIPlus The SFML functions used in the tests and demos will be available in the SFML UDF post (see reference above).
      EXAMPLES:
      For such a powerful physics engine coupled to such a powerful graphics engine (SFML) it's sad that I've only had time to build one functional game, thus far.  But it's a start.
      My self-titled "Angry Nerds" is merely a demo of the same game concept as the ever-so-popular Angry Birds game.  Angry Birds itself is built on top of Box2D.  Likewise Angry Nerds.  AutoIT + Box2D + SFML to be exact.  I've compiled Angry Nerds and provided an installer also, so you can quickly run the demo for yourself.  From the Github site below (in the DOWNLOAD section) run "Box2C_Angry_Nerds_Game_SFML_installer.exe" to install the demo to a location on your computer (desktop by default).  Go into this folder and run "Box2C_Angry_Nerds_Game_SFML.exe".  All instructions are displayed in-game.  Should be quite easy to work out.
      Aside from Angry Nerds there are also two test scripts:
      Box2C_linear_forces_test_SFML.au3 Box2C_angular_forces_test_SFML.au3 Feel free to run these for a basic demonstration of rigid bodies, forces and collisions.  The heart of Box2D and any physics engine.
      Lastly I also have four speed tests as follows:
      Box2C_speed_test_SFML.au3 Box2C_speed_test_Irrlicht.au3 Box2C_speed_test_D2D.au3 Box2C_speed_test_GDIPlus.au3 These were my initial evaluations into a suitable graphics engine for Box2D.  I've since settled on SFML, but feel free to execute these.  Note they may become quick defective over time as the SFML functions slowly take over.
      DOWNLOADS:
      You can download this UDF, including the examples above and associated files, from the following GitHub page:
      https://github.com/seanhaydongriffin/Box2C-UDF
      Hope you all enjoy!  I certainly am :-)
      Cheers,
      Sean.
       
    • Triblade
      By Triblade
      Hi folks!
       
      First off, yeah this may be the lamest title. But it made you look anyway! 
       
      Edit: Now updated! With step-counter, reset button and a few GUI-tweaks. (the step-counter is cheating! It's calculated in advance...)
      I recently thought a screenshot of a finished maze may be smart to show, instead of only my long story and code. o=path, x=wall. Here it is:
       

       
      I started making my own implementation of the A* pathing script in a larger project, inspired by Toady's work. (But made one from scratch myself anyway )
      After the A* pathing script was working (not cleaned up yet) I wanted to test it. Unfortunately I got no good, randomized, maze lying around that also had the format I needed. So I made my own maze generator!
       
      I did a few hours of research on the matter and then a few evenings of scripting.
      For the people who are interested, one of my problems was that I needed 'one-cell' thick walls. Most maze generation have 1 pixel thick walls drawn by a line, that could be opened if a path is needed. The solution is so simple, I needed this guy to tell me. Click here for my inspiration source.
       
      This generator can be used with different sizes maze, even uneven ones! Just set the width and height settings. FYI, it must be odd numbers for this maze to work with it's containment walls.
      It's the 'simple' Depth-First Search, with backtracking. And without further ado; my a-maze-ing generator!:
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: A-maze-ing generator Script Function: Generates a maze. In the $xy[$i][4] is the maze in array form. Don't forget to take the size with it, else it's just a string of o's and x's It does not generate an entrance or exit! #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; Set various variables ; width and height must be odd numbers to have a closed, functioning maze. Global $height = 27 ; demo height = 27 Global $width = 43; demo width = 43 ; Check if width & height are an odd number (to get the outer edge an odd number is required) If mod($height, 2) = 0 Or $height < 5 Then msgbox(0,"","Height is not an odd number or a minimum of 5 tall !") Exit ElseIf mod($width, 2) = 0 Or $width < 5 Then msgbox(0,"","Width is not an odd number of a minimum of 5 wide !") Exit EndIf ; Set various variables when script is not exited Global $grid_size = $height * $width Global $numberofsteps = (Ceiling(($height-2) / 2) * (($width-2) - Ceiling(($width-2) / 2))) + (($height-2) - Ceiling(($height-2) / 2)) ; long formula to check the number of steps this maze will take, this is a mathematical given with a fixed number of cells. And yes, I am aware I'm taking a shortcut in this formula. ;) Global $curpos Global $backtrack[1] Global $bt = 0 Local $grid_pixel = 20 ;How many pixels per square ; Initialize main array with all grid data Global $xy[$grid_size + 1][5] Global $reset_xy = $xy ; set the reset array $xy[0][0] = $grid_size ; first entry is the total number of nodes, rest is set with a header name for easy reference in _ArrayDisplay if needed. $xy[0][1] = "ID" $xy[0][2] = "Row" $xy[0][3] = "Column" $xy[0][4] = "Type" ; Fill the grid array with 'walls' For $i = 1 To $xy[0][0] $xy[$i][4] = "x" Next ; Start GUI and create standard buttons Local $gui = GUICreate("A-maze-ing generator", 180 + ($width * $grid_pixel), 80 + ($height * $grid_pixel)) ; Set the main window to the minimum width (IF) needed for the msgbox Local $aPos = WinGetPos($gui) If $aPos[2] < 696 Then $aPos[2] = 696 WinMove($gui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) EndIf GUICtrlCreateLabel("This is a-maze-ing!", 30, 19) Global $progress = GUICtrlCreateLabel("Standing by... " & $numberofsteps & " steps to go.", 150, 15, 550, 30) Local $iOKButton = GUICtrlCreateButton("Start", 45, 50, 60) Local $iResetButton = GUICtrlCreateButton("Reset", 45, 90, 60) Local $iExitButton = GUICtrlCreateButton("Exit", 45, 130, 60) GUICtrlSetFont($progress, 15) GUICtrlSetColor($progress, 0x00AA00) GUICtrlSetState($iResetButton, $GUI_DISABLE) ; Create label-grid and fill the xy array with the positions Local $squarenr = 0 For $i = 0 To ($height * $grid_pixel) - $grid_pixel Step $grid_pixel ; Row For $j = 0 To ($width * $grid_pixel) - $grid_pixel Step $grid_pixel ; Column $squarenr = $squarenr + 1 $xy[$squarenr][0] = GUICtrlCreateLabel('x', 150 + $j, 50 + $i, $grid_pixel, $grid_pixel, BitOr($SS_SUNKEN, $SS_CENTER)) ; if you want debugging numbers, replace 'x' with $squarenr GUICtrlSetBkColor($xy[$squarenr][0], 0x5E87C9) ; lightblue-ish $xy[$squarenr][1] = $squarenr $xy[$squarenr][2] = ($i / $grid_pixel) + 1 $xy[$squarenr][3] = ($j / $grid_pixel) + 1 Next Next $reset_xy = $xy ; Show GUI GUISwitch($gui) GUISetState(@SW_SHOW) ; Start looping and waiting for input Local $aMsg = 0 While 1 $aMsg = GUIGetMsg(1) Select Case $aMsg[0] = $iOKButton GUICtrlSetState($iOKButton, $GUI_DISABLE) GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iExitButton, $GUI_DISABLE) GUICtrlSetColor($progress, 0xFF8C00) ; orange GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $numberofsteps & " steps to go.") make_maze() GUICtrlSetColor($progress, 0xFF0000) ; red GUICtrlSetData($progress, "Maze complete!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetColor($progress, 0x00AA00) ; green-ish GUICtrlSetData($progress, "Maze completed in " & $numberofsteps & " steps.") GUICtrlSetState($iResetButton, $GUI_ENABLE) GUICtrlSetState($iExitButton, $GUI_ENABLE) Case $aMsg[0] = $iResetButton GUICtrlSetData($progress, "Resetting maze...") reset_maze() GUICtrlSetState($iResetButton, $GUI_DISABLE) GUICtrlSetState($iOKButton, $GUI_ENABLE) GUICtrlSetData($progress, "Maze reset!") Sleep(1000) ; Just a small sleep for dramatic effect GUICtrlSetData($progress, "Standing by...") Case $aMsg[0] = $GUI_EVENT_CLOSE Or $aMsg[0] = $iExitButton ExitLoop EndSelect WEnd Exit ; Resetting the maze to default state Func reset_maze() $xy = $reset_xy ; Set the $xy array back to it first-run values For $i = 1 To $xy[0][0] $xy[$i][4] = "x" ; set everything to 'x' GUICtrlSetBkColor($xy[$i][0], 0x5E87C9) ; reset the background color GUICtrlSetData($xy[$i][0], "x") ; (re)set the label to 'x' Next EndFunc ; Main function Func make_maze() Local $heading Local $stepcount = $numberofsteps ; Reset the step counter. Local $timed = TimerInit() ; Start the timer to see how long the maze generation took. $backtrack[0] = 0 $curpos = $width + 2 ; This is the starting position, second row, second column - aka top-left, one in from the sides. open_maze($curpos) ; Set the starter cell to 'open / white' ; Main maze generation loop While 1 Do $heading = direction($curpos) Until $heading <> 0 If $bt = 1 Then $bt = 0 ; reset backtracking-tracker, else the backtracking array keeps adding the current position GUICtrlSetData($progress, "Running - Creating maze. Please stand by... " & $stepcount & " steps to go.") Sleep(50) ; Slow maze creation down to look at it - relax! (or don't and comment out the sleep) If $heading = -1 Then ExitLoop $stepcount -= 1 ; Count down the steps to finish. ; We got the heading - now which way do we go? After that, set the current position to the last known heading. Switch $heading Case 1 ; north open_maze($curpos - $width) open_maze($curpos - ($width * 2)) $curpos = $curpos - ($width * 2) Case 2 ; east open_maze($curpos + 1) open_maze($curpos + 2) $curpos = $curpos + 2 Case 3 ; south open_maze($curpos + $width) open_maze($curpos + ($width * 2)) $curpos = $curpos + ($width * 2) Case 4 ; west open_maze($curpos - 1) open_maze($curpos - 2) $curpos = $curpos - 2 EndSwitch ;msgbox(0,"","Turn pause") ; for debugging, click every turn. WEnd ConsoleWrite("Maze completed in " & Round(TimerDiff($timed) / 1000, 1) & " seconds." & @CRLF) ; Show the generation time in seconds, rounded up with one decimal Return EndFunc Func open_maze($dest) ; Function set inputted cells to 'open' instead of being an uncool wall. $xy[$dest][4] = "o" GUICtrlSetData($xy[$dest][0], 'o') ; If you want debugging numbers, replace 'o' with $dest GUICtrlSetBkColor($xy[$dest][0], 0xEEEEEE) EndFunc Func direction(ByRef $curpos) ; Insert current position, output next heading for path generation. Local $nesw Local $open_directions[5][2] $open_directions[0][0] = 0 $nesw = $curpos - ($width * 2) ; north side checking If $nesw > $width + 1 Then fill_open_dir($nesw, 1, $open_directions) $nesw = $curpos + 2 ; east side checking If mod($nesw - 1, $width) <> 0 Then fill_open_dir($nesw, 2, $open_directions) $nesw = $curpos + ($width * 2) ; south side checking If $nesw < $grid_size - $width Then fill_open_dir($nesw, 3, $open_directions) $nesw = $curpos - 2 ; west side checking If mod($nesw, $width) <> 0 Then fill_open_dir($nesw, 4, $open_directions) ; Check which (if any) direction(s) are already opened, if so, discard them from the results-array For $i = $open_directions[0][0] To 1 Step -1 If $xy[$open_directions[$i][1]][4] = "o" Then $open_directions[0][0] -= 1 _ArrayDelete($open_directions, $i) EndIf Next ; If there are any results left... If $open_directions[0][0] > 0 Then If $open_directions[0][0] = 1 Then Return $open_directions[1][0] ; Random does not work with min 1 and max 1 (output = 0), so in this case, return only with the only one result. Else If $bt = 0 Then ; If there is not backtracking active, add this crossroad to the backtrack-array. This is only needed if there are two or three possible sides. $backtrack[0] += 1 _ArrayAdd($backtrack, $curpos) EndIf Return $open_directions[Random(1, $open_directions[0][0], 1)][0] ; Random choose between all possible directions and return with the outcome direction. EndIf ElseIf $backtrack[0] > 0 Then ; If there are no results ánd there are entries in the backtrack list, then visit those entries to see if there still is a path possible. $curpos = $backtrack[$backtrack[0]] _ArrayDelete($backtrack, $backtrack[0]) $backtrack[0] -= 1 $bt = 1 Return 0 ; Return with a new current direction ($curpos), from the backtrack array. Else Return -1 ; If there are no paths to explorer, in the pathing, or backtracking, then return with the message that we are finished. EndIf EndFunc Func fill_open_dir($nesw, $direction, ByRef $open_directions) ; Fill the $open_directions array with a new possible way $open_directions[0][0] += 1 $open_directions[$open_directions[0][0]][1] = $nesw $open_directions[$open_directions[0][0]][0] = $direction Return EndFunc  
      P.S.  The 'slow' generation is intended because it looks cool. Comment out the Sleep line on line 157 for a fast generation.
    • rm4453
      By rm4453
      Hey guys! I need to find a way to wrap an autoit gui around a game. I am planning on making a custom gui overlay for interacting with my stream, which will allow me to run giveaways and stuff like that. But I need to find a way to force the steam games to run inside my autoit gui... I have the following code so far credit to those I took code from and modified to suite my needs "can't remember who u are pls post if i owe ty to u" If I select notepad and launch it then it works great! and the notepad window is wrapped inside my gui. However if I try it with teamfortress 2 it won't work...
       
      #include <Array.au3> #include <File.au3> #include <WinAPI.au3> #include <GUIConstants.au3> Local $msg, $hwnd, $WinHwnd ;===> UDV Start $pid = 0 $Hidden = 0 $exe = 0 $sDrive = 0 $sDir = 0 $sFileName = 0 $sExtension = 0 ;===> UDV End $hwnd = GUICreate("hello") $Open = GUICtrlCreateButton("Launch Game", 10, 30, 75, 25) $Select = GUICtrlCreateButton("Select Game", 10,60,75,25) GUISetState() ;===> UDF START Func _GetWinHwnd($pid) $aWinlist = WinList() For $i = 1 To $aWinlist[0][0] If $pid = WinGetProcess($aWinlist[$i][0]) Then Return $aWinlist[$i][0] Next EndFunc ;==>_GetWinHwnd Func _SetParentWindow($pid) $WinInfo = _GetWinHwnd($pid) $WinHwnd = ControlGetHandle($WinInfo, "", "") _WinAPI_SetParent($WinHwnd, $hwnd) _WinAPI_SetWindowLong($WinHwnd, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE) WinMove($WinHwnd, "", 0, 0) EndFunc ;==>_SetParentWindow Func RedrawGui($RedrawMe) If ProcessExists($pid) And $Hidden = 0 Then GUICtrlSetState($RedrawMe, @SW_HIDE) $Hidden = 1 sleep(50) _WinAPI_RedrawWindow($pid) Sleep(50) ElseIf $Hidden = 1 And Not ProcessExists($pid) Then GUICtrlSetState($RedrawMe, @SW_SHOW) $Hidden = 0 EndIf EndFunc ;===> UDF END While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If ProcessExists($pid) Then ProcessClose($pid) GUICtrlSetState($Open, @SW_SHOW) Else Exit EndIf Case $Open GUICtrlSetState($Open, @SW_HIDE) Sleep(100) $pid = Run('"' & $exe & '" -game tf -steam') #cs This RUN CMD is custom made for testing with TF2 change to just $exe to select any exe you want to test with -game tf specifies to launch tf2 and -steam gets rid of insecure mode error #ce RedrawGui($Open) ProcessWait($pid) Sleep(5500) _GetWinHwnd($pid) _SetParentWindow($pid) Case $Select $exe = FileOpenDialog("Please select your game!", @ScriptDir, "Executable File (*.exe)", "1", "Process Selection") Sleep(50) FileChangeDir(@ScriptDir) _PathSplit($exe, $sDrive, $sDir, $sFileName, $sExtension) EndSwitch WEnd  
    • Wingens
      By Wingens
      Hi,
      I don't know if it is possible but I am creating a little program to catalog my game collection.
      It would be awesome if my program could get the boxcover, developer info and game info with the titles I add.
      Does anyone know how to get me started?