xan Posted October 21, 2017 Share Posted October 21, 2017 expandcollapse popupLocal $mx, $b[16], $bx[16], $by[16], $bn[16], $win, $enf, $rnd[16], $fr, $loop, $nMsg mix() While $nMsg <> -3 $nMsg = GUIGetMsg() If $nMsg = $mx Then mix() ; Botão mix If Not $loop Then For $i = 0 To 15 ; movimenta os botões selecionados Switch $nMsg Case $b[$i] GUICtrlSetBkColor($b[$i], 0x00cc33) Sleep(190) GUICtrlSetBkColor($b[$i], 0xffffff) if $i = 0 or $i = 4 Or $i = 8 Or $i = 12 Then pos($i, 2, 1, 1) if $i = 1 or $i = 5 Or $i = 9 Or $i = 13 Then pos($i, 1, 1, 1) if $i = 2 or $i = 6 Or $i = 10 Or $i = 14 Then pos($i, 0, 1, 1) if $i = 1 or $i = 5 Or $i = 9 Or $i = 13 Then pos($i, 0, -1, -1) if $i = 2 or $i = 6 Or $i = 10 Or $i = 14 Then pos($i, 1, -1, -1) if $i = 3 or $i = 7 Or $i = 11 Or $i = 15 Then pos($i, 2, -1, -1) if $i < 4 Then pos($i, 2, 4, 4) if $i > 3 And $i < 8 Then pos($i, 1, 4, 4) if $i > 7 And $i < 12 Then pos($i, 0, 1, 4) if $i > 3 And $i < 8 Then pos($i, 0, -4, -4) if $i > 7 And $i < 12 Then pos($i, 1, -4, -4) if $i > 11 Then pos($i, 2, -4, -4) Case -3 Exit EndSwitch GUICtrlSetPos($b[$i], $bx[$i], $by[$i]) ; Atualiza as posições dos botões If $bn[$i] <> $i + 1 Then $win = 1 ; Verifica se os botãoes estão ordenados Next EndIf If Not $win Then ; Animaçã da vitória If $loop < 2 Then For $i = 0 To 30 If $i < 16 Then GUICtrlSetBkColor($b[$i], Random(100, 10000, 1) * 5572 + $i * Random(100, 10000, 1)) If $i > 15 Then GUICtrlSetBkColor($b[$i-16], 0xffffff) Beep(Random(30, 100, 1) * $i, 250) Next EndIf $loop += 1 EndIf $win = 0 WEnd Func pos($n, $p, $sinal, $step) ; combinação para movimento dos botões For $i = $p To 0 Step - 1 if $bn[$n + $sinal * $i + $step] = 16 Then $aux = $b[$n + $sinal * $i] $b[$n + $sinal * $i]= $b[$n + $sinal * $i + $step] $b[$n + $sinal * $i + $step] = $aux $aux = $bn[$n + $sinal * $i] $bn[$n + $sinal * $i] = $bn[$n + $sinal * $i + $step] $bn[$n + $sinal * $i + $step] = $aux EndIf Next $nMsg = 0 EndFunc Func mix() ;Cria e embaralha os botões GUIDelete($fr) $fr = GUICreate("Autoit", 510, 560, 300, 50) GUISetBkColor(0xe8c70e) GUICtrlCreateLabel("JOGO DOS 15", 30, 15, 430, 70, 1) GUICtrlSetFont(-1, 54, 800, 0, "MS Sans Serif") $bt = GUICtrlCreateButton("", 38, 78, 434, 429) GUIctrlSetState(-1,128) $mx = GUICtrlCreateLabel("M i x", 422, 530, 50, 20, 1, 1) GUISetState() For $i = 0 To 3 ;gera as posições dos botões For $j = 0 To 3 $bx[$j + $i * 4] = $i * 3 + $j * 110 + 40 - 3 * $i $by[$j + $i * 4] = $i * 3 + $i * 105 + 80 Next Next $win = 0 $loop = 0 For $i = 0 to 15 Do $b[$i] = 0 $enf = 1 $rnd[$i] = Random(0, 15, 1) For $j = 0 To $i For $k = 0 To $i If $j <> $k And $rnd[$k] = $rnd[$j] Then $enf = 0 Next Next Until $enf $bn[$i] = $rnd[$i] + 1 If $rnd[$i] < 15 Then $b[$i] = GUICtrlCreateButton($rnd[$i] + 1, $bx[$i], $by[$i], 100, 100) GUICtrlSetBkColor($b[$i], 0xffffff) GUICtrlSetFont($b[$i], 50, 800, 0, "MS Sans Serif") EndIf Next EndFunc Gianni and Fabio_iGames 2 Link to comment Share on other sites More sharing options...
Fabio_iGames Posted October 21, 2017 Share Posted October 21, 2017 1 hour ago, xan said: expandcollapse popupLocal $mx, $b[16], $bx[16], $by[16], $bn[16], $win, $enf, $rnd[16], $fr, $loop, $nMsg mix() While $nMsg <> -3 $nMsg = GUIGetMsg() If $nMsg = $mx Then mix() ; Botão mix If Not $loop Then For $i = 0 To 15 ; movimenta os botões selecionados Switch $nMsg Case $b[$i] GUICtrlSetBkColor($b[$i], 0x00cc33) Sleep(190) GUICtrlSetBkColor($b[$i], 0xffffff) if $i = 0 or $i = 4 Or $i = 8 Or $i = 12 Then pos($i, 2, 1, 1) if $i = 1 or $i = 5 Or $i = 9 Or $i = 13 Then pos($i, 1, 1, 1) if $i = 2 or $i = 6 Or $i = 10 Or $i = 14 Then pos($i, 0, 1, 1) if $i = 1 or $i = 5 Or $i = 9 Or $i = 13 Then pos($i, 0, -1, -1) if $i = 2 or $i = 6 Or $i = 10 Or $i = 14 Then pos($i, 1, -1, -1) if $i = 3 or $i = 7 Or $i = 11 Or $i = 15 Then pos($i, 2, -1, -1) if $i < 4 Then pos($i, 2, 4, 4) if $i > 3 And $i < 8 Then pos($i, 1, 4, 4) if $i > 7 And $i < 12 Then pos($i, 0, 1, 4) if $i > 3 And $i < 8 Then pos($i, 0, -4, -4) if $i > 7 And $i < 12 Then pos($i, 1, -4, -4) if $i > 11 Then pos($i, 2, -4, -4) Case -3 Exit EndSwitch GUICtrlSetPos($b[$i], $bx[$i], $by[$i]) ; Atualiza as posições dos botões If $bn[$i] <> $i + 1 Then $win = 1 ; Verifica se os botãoes estão ordenados Next EndIf If Not $win Then ; Animaçã da vitória If $loop < 2 Then For $i = 0 To 30 If $i < 16 Then GUICtrlSetBkColor($b[$i], Random(100, 10000, 1) * 5572 + $i * Random(100, 10000, 1)) If $i > 15 Then GUICtrlSetBkColor($b[$i-16], 0xffffff) Beep(Random(30, 100, 1) * $i, 250) Next EndIf $loop += 1 EndIf $win = 0 WEnd Func pos($n, $p, $sinal, $step) ; combinação para movimento dos botões For $i = $p To 0 Step - 1 if $bn[$n + $sinal * $i + $step] = 16 Then $aux = $b[$n + $sinal * $i] $b[$n + $sinal * $i]= $b[$n + $sinal * $i + $step] $b[$n + $sinal * $i + $step] = $aux $aux = $bn[$n + $sinal * $i] $bn[$n + $sinal * $i] = $bn[$n + $sinal * $i + $step] $bn[$n + $sinal * $i + $step] = $aux EndIf Next $nMsg = 0 EndFunc Func mix() ;Cria e embaralha os botões GUIDelete($fr) $fr = GUICreate("Autoit", 510, 560, 300, 50) GUISetBkColor(0xe8c70e) GUICtrlCreateLabel("JOGO DOS 15", 30, 15, 430, 70, 1) GUICtrlSetFont(-1, 54, 800, 0, "MS Sans Serif") $bt = GUICtrlCreateButton("", 38, 78, 434, 429) GUIctrlSetState(-1,128) $mx = GUICtrlCreateLabel("M i x", 422, 530, 50, 20, 1, 1) GUISetState() For $i = 0 To 3 ;gera as posições dos botões For $j = 0 To 3 $bx[$j + $i * 4] = $i * 3 + $j * 110 + 40 - 3 * $i $by[$j + $i * 4] = $i * 3 + $i * 105 + 80 Next Next $win = 0 $loop = 0 For $i = 0 to 15 Do $b[$i] = 0 $enf = 1 $rnd[$i] = Random(0, 15, 1) For $j = 0 To $i For $k = 0 To $i If $j <> $k And $rnd[$k] = $rnd[$j] Then $enf = 0 Next Next Until $enf $bn[$i] = $rnd[$i] + 1 If $rnd[$i] < 15 Then $b[$i] = GUICtrlCreateButton($rnd[$i] + 1, $bx[$i], $by[$i], 100, 100) GUICtrlSetBkColor($b[$i], 0xffffff) GUICtrlSetFont($b[$i], 50, 800, 0, "MS Sans Serif") EndIf Next EndFunc You're here ... teacher Very good. You are amazing. xan 1 Link to comment Share on other sites More sharing options...
wakillon Posted October 22, 2017 Share Posted October 22, 2017 Good work Thanks xan 1 AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now