Jump to content

Recommended Posts

Posted (edited)

This is a script I am building to emulate this puzzle.

The script is incomplete but you can at least see some of the initial workings.

The next step is to work out the actual puzzles.

  Reveal hidden contents

Edited by spudw2k
Posted

Hello,

it can help you finish up ;)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiSlider.au3>
Dim $arrSliders[4][2]
Dim $arrLabels[4][2]
$Form1 = GUICreate("", 422, 291)
$arrSliders[0][0] = GUICtrlCreateSlider(112, 104, 38, 149, BitOR($TBS_VERT,$TBS_BOTH,0x8000))
GUICtrlSetData(-1,100)
$arrSliders[1][0] = GUICtrlCreateSlider(186, 105, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$arrSliders[2][0] = GUICtrlCreateSlider(264, 105, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$arrSliders[3][0] = GUICtrlCreateSlider(343, 105, 38, 149, BitOR($TBS_VERT,$TBS_BOTH))
GUICtrlSetData(-1,100)
$LevelSelect = GUICtrlCreateInput("0", 36, 230, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY))
$UpDown = GUICtrlCreateUpdown($LevelSelect)
GUICtrlSetLimit(-1,10,0)
$Reset = GUICtrlCreateButton("Reset", 24, 160, 67, 41)
$arrLabels[0][0] = GUICtrlCreateLabel("0", 128, 252, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[1][0] = GUICtrlCreateLabel("0", 202, 252, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[2][0] = GUICtrlCreateLabel("0", 280, 252, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[3][0] = GUICtrlCreateLabel("0", 359, 252, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[0][1] = GUICtrlCreateLabel("1", 128, 86, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[1][1] = GUICtrlCreateLabel("1", 202, 86, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[2][1] = GUICtrlCreateLabel("1", 280, 86, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$arrLabels[3][1] = GUICtrlCreateLabel("1", 359, 86, 10, 17)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$lblTitle = GUICtrlCreateLabel("4-bit Puzzle", 144, 16, 140, 33)
GUICtrlSetFont(-1, 18, 800, 4, "MS Sans Serif")
GUIRegisterMsg($WM_VSCROLL, "WM_Slider")
GUICtrlSetState($lblTitle,$GUI_FOCUS)
GUISetState(@SW_SHOW)
_EvalSliders()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Reset
            _Reset()
        Case $UpDown
            _Reset()
        Case $arrLabels[0][0]
   ArrLabels(0, 0)
        Case $arrLabels[1][0]
   ArrLabels(1, 0)
        Case $arrLabels[2][0]
   ArrLabels(2, 0)
        Case $arrLabels[3][0]
   ArrLabels(3, 0)
        Case $arrLabels[0][1]
   ArrLabels(0, 1)
        Case $arrLabels[1][1]
   ArrLabels(1, 1)
        Case $arrLabels[2][1]
   ArrLabels(2, 1)
        Case $arrLabels[3][1]
   ArrLabels(3, 1)
        Case $GUI_EVENT_PRIMARYUP
            _EvalSliders()
    EndSwitch
WEnd
Func ArrLabels($x, $y)
If $y = 1 Then
  If $arrSliders[$x][1]=100 Then
   $arrSliders[$x][1]=_SlideUp($arrSliders[$x][0])
   WM_Slider($Form1, 0x000, 0xfff,GUICtrlGetHandle($arrSliders[$x][0]))
  EndIf
Else
  If $arrSliders[$x][1]=0 Then $arrSliders[$x][1]=_SlideDown($arrSliders[$x][0])
EndIf
EndFunc
Func _Reset()
    GUICtrlSetState($Reset,$GUI_DISABLE)
    GUICtrlSetState($lblTitle,$GUI_FOCUS)
    _SlideUp($arrSliders)
    _SlideDown($arrSliders)
    GUICtrlSetState($Reset,$GUI_ENABLE)
EndFunc
Func _EvalSliders()
    For $x = 0 to 3
        $arrSliders[$x][1] = _GUICtrlSlider_GetPos($arrSliders[$x][0])
        $pos = $arrSliders[$x][1]
        If $pos > 0 AND $pos < 100 Then
            If $pos > 50 Then
                $arrSliders[$x][1]=_SlideDown($arrSliders[$x][0])
            Else
                $arrSliders[$x][1]=_SlideUp($arrSliders[$x][0])
            EndIf
        EndIf
    Next
EndFunc
Func _SlideUp($hwnd)
    If IsArray($hwnd) Then
        For $x = 0 to UBound($hwnd)-1
            $hwnd[$x][1] = 100-_GUICtrlSlider_GetPos($hwnd[$x][0])
        Next
        For $pos = 25 to 100
            For $x = 0 to UBound($hwnd)-1
                _GUICtrlSlider_SetPos($hwnd[$x][0],(100-_QuinticEaseInOut($pos, $hwnd[$x][1], 100, 100)))
                If _GUICtrlSlider_GetPos($hwnd[$x][0]) <= 2 Then
                    _GUICtrlSlider_SetPos($hwnd[$x][0],0)
     ContinueLoop
                EndIf
            Next
   Sleep(10)
        Next
    Else
        $start = 100-_GUICtrlSlider_GetPos($hwnd)
        For $pos = 25 to 100
            _GUICtrlSlider_SetPos($hwnd,(100-_QuinticEaseInOut($pos, $start, 100, 100)))
            If _GUICtrlSlider_GetPos($hwnd) <= 2 Then
                _GUICtrlSlider_SetPos($hwnd,0)
    Return 0
            EndIf
   Sleep(10)
        Next
    EndIf
EndFunc
Func _SlideDown($hwnd)
    If IsArray($hwnd) Then
        For $x = 0 to UBound($hwnd)-1
            $hwnd[$x][1] = _GUICtrlSlider_GetPos($hwnd[$x][0])
        Next
        For $pos = 25 to 100
            For $x = 0 to UBound($hwnd)-1
                _GUICtrlSlider_SetPos($hwnd[$x][0],(_QuinticEaseInOut($pos, $hwnd[$x][1], 100, 100)))
                If _GUICtrlSlider_GetPos($hwnd[$x][0]) >= 98 Then
                    _GUICtrlSlider_SetPos($hwnd[$x][0],100)
     ContinueLoop
                EndIf
            Next
   Sleep(10)
        Next
    Else
        $start = _GUICtrlSlider_GetPos($hwnd)
        For $pos = 25 to 100
            _GUICtrlSlider_SetPos($hwnd,(_QuinticEaseInOut($pos, $start, 100, 100)))
            If _GUICtrlSlider_GetPos($hwnd) >= 98 Then
                _GUICtrlSlider_SetPos($hwnd,100)
    Return 100
            EndIf
   Sleep(10)
        Next
    EndIf
EndFunc
Func WM_Slider($hWnd, $iMsg, $wParam, $lParam)
    ;ConsoleWrite($wParam & ":" & $lParam & ":" & _GUICtrlSlider_GetPos($lParam) & @CRLF & @CRLF)
If $wParam=0xfff Then
  Local $wArray[3][2]
  $wArray[2][0]=0
EndIf
    Switch $lParam
  Case GUICtrlGetHandle($arrSliders[0][0])
   If $wParam=0xfff Then
    If Not $arrSliders[1][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[1][0]
     $wArray[2][0]+=1
    EndIf
    If Not $arrSliders[3][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[3][0]
     $wArray[2][0]+=1
    EndIf
   Else
    $pos = _GUICtrlSlider_GetPos($arrSliders[0][0])
    If Not $arrSliders[1][1] Then _GUICtrlSlider_SetPos($arrSliders[1][0],100-$pos)
    If Not $arrSliders[3][1] Then _GUICtrlSlider_SetPos($arrSliders[3][0],100-$pos)
   EndIf
        Case GUICtrlGetHandle($arrSliders[1][0])
   If $wParam=0xfff Then
    If Not $arrSliders[2][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[2][0]
     $wArray[2][0]+=1
    EndIf
    If Not $arrSliders[0][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[0][0]
     $wArray[2][0]+=1
    EndIf
   Else
    $pos = _GUICtrlSlider_GetPos($arrSliders[1][0])
                If Not $arrSliders[2][1] Then _GUICtrlSlider_SetPos($arrSliders[2][0],100-$pos)
                If Not $arrSliders[0][1] Then _GUICtrlSlider_SetPos($arrSliders[0][0],100-$pos)
            EndIf
        Case GUICtrlGetHandle($arrSliders[2][0])
   If $wParam=0xfff Then
    If Not $arrSliders[1][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[1][0]
     $wArray[2][0]+=1
    EndIf
    If Not $arrSliders[0][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[0][0]
     $wArray[2][0]+=1
    EndIf
   Else
    $pos = _GUICtrlSlider_GetPos($arrSliders[2][0])
                If Not $arrSliders[1][1] Then _GUICtrlSlider_SetPos($arrSliders[1][0],100-$pos)
                If Not $arrSliders[0][1] Then _GUICtrlSlider_SetPos($arrSliders[0][0],100-$pos)
            EndIf
        Case GUICtrlGetHandle($arrSliders[3][0])
   If $wParam=0xfff Then
    If Not $arrSliders[2][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[2][0]
     $wArray[2][0]+=1
    EndIf
    If Not $arrSliders[1][1] Then
     $wArray[$wArray[2][0]][0]=$arrSliders[1][0]
     $wArray[2][0]+=1
    EndIf
   Else
    $pos = _GUICtrlSlider_GetPos($arrSliders[3][0])
                If Not $arrSliders[2][1] Then _GUICtrlSlider_SetPos($arrSliders[2][0],100-$pos)
                If Not $arrSliders[1][1] Then _GUICtrlSlider_SetPos($arrSliders[1][0],100-$pos)
            EndIf
    EndSwitch
If $wParam=0xfff Then
  If $wArray[2][0]>0 Then
   ReDim $wArray[$wArray[2][0]][2]
   _SlideDown($wArray)
  EndIf
EndIf
    Return $GUI_RUNDEFMSG
EndFunc
Func _QuinticEaseInOut($iFrame, $iStartValue, $iInterval, $iEndValue) ;Credit to Josh Rowe - http://autoitscript.com/forum/topic/102851-transitions-udf/
    $iFrame = $iFrame / ($iEndValue / 2)
    If $iFrame < 1 Then
        Return $iInterval / 2 * $iFrame * $iFrame * $iFrame * $iFrame * $iFrame + $iStartValue
    EndIf
    $iFrame = $iFrame - 2
    Return $iInterval / 2 * ($iFrame * $iFrame * $iFrame * $iFrame * $iFrame + 2) + $iStartValue
EndFunc ;==>_QuinticEaseInOut

greets wilenty. :)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...