Jump to content

Autoit Simon


lordicast
 Share

Recommended Posts

Like the game tried to make a version using just graphics in autoit try it out.

Small bug if you move really fast it doesnt give time to read the Pixel.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $all, $byNum, $Check, $EXall, $EXall2, $LogNum, $Pos
Global $Zcas = 1
$Turn = 0
Global $Ka = 0
Global $obj
Global $iSleep = 300
$High = 0
HotKeySet('{esc}', 'end')

Global $a, $AA
$Form1 = GUICreate("AutoIt Simon", 450, 455, 192, 138)
$Level = GUICtrlCreateLabel('Level: ' & 1, 20, 10, 80, 24)
$Begin = GUICtrlCreateButton('Start', 186, 200, 80, 25)
$Score = GUICtrlCreateButton('High Score', 186, 235, 80, 25)
GraphicMain()
GUISetState(@SW_SHOW)


While 1
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            PixCheck()
        Case $Begin
            aSimon()
        Case $Score
            MsgBox(64, 'High Score', 'Level : ' & $High)
    EndSwitch
WEnd

Func PixCheck()
    Global $Pos = MouseGetPos()
    $Pix = PixelGetColor($Pos[0], $Pos[1])
    $Pix = Hex($Pix)
    If $Ka = 1 Then
        If $Pix = '00ffd700' Then
            $SHOUT = 1
            Checking($SHOUT)
        ElseIf $Pix = '00cd0000' Then
            $SHOUT = 2
            Checking($SHOUT)
        ElseIf $Pix = '000000bb' Then
            $SHOUT = 3
            Checking($SHOUT)
        ElseIf $Pix = '00008b00' Then
            $SHOUT = 4
            Checking($SHOUT)
        Else
            Sleep(10)
        EndIf
    EndIf
EndFunc   ;==>PixCheck

Func Checking($Pattern)
    If $LogNum = 0 Then
        $LogNum = $LogNum + 1
    EndIf
    $EXall2 = $EXall
    $leng = StringLen($EXall2)
    If $obj = $leng Then
        aSimon()
    Else
        Global $Check = StringMid($EXall2, $LogNum, 1)
        If $Check = $Pattern Then
            Global $obj = $leng - $LogNum
            $DeNum = $LogNum + 1
            Global $LogNum = ''
            Global $LogNum = $DeNum
            If $obj = 0 Then
                ToolTip('Correct', $Pos[0], $Pos[1])
                Sleep(1000)
                ToolTip('')
                aSimon()
            EndIf
            If $obj = $leng Then
                ToolTip('Correct', $Pos[0], $Pos[1])
                Sleep(1000)
                ToolTip('')
                aSimon()
            EndIf
        Else
            Beep(30)
            MsgBox(0, 'WaWaWa', 'Game Over')

            $New = $byNum
            If $New > $High Then
                Global $High = $New
            EndIf
            Global $all = ''
            $byNum = ''
            GUICtrlSetData($Level, '')
            GUICtrlSetData($Level, 'Level: ' & $byNum)
        EndIf
    EndIf
EndFunc   ;==>Checking

Func aSimon()
    Global $LogNum = 0

    BlockInput(1)
    $c = Random(1, 4, 1)
    Global $EXall = $all & $c
    $all = $all & $c
    $byNum = StringLen($all)
    GUICtrlSetData($Level, '')
    GUICtrlSetData($Level, 'Level: ' & $byNum)
    For $i = 1 To $byNum Step 1
        Call('a' & StringMid($all, $i, 1))
        Sleep($iSleep)
    Next
    BlockInput(0)
    Global $Ka = 1

EndFunc   ;==>aSimon

Func end()
    Exit
EndFunc   ;==>end



Func GraphicMain()
    If $AA Then
        GUICtrlDelete($AA)
    EndIf

    $AA = GUICtrlCreateGraphic(0, 0, 400, 400)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 230, 220, 360, 360)
    ;yellow

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFFD700)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 190, 80)
    ;Red

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xCD0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 10, 80)
    ;Blue

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x0000bb)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 280, 80)
    ;Green

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x008b00)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 100, 80)

    ;bCircle
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 90, 360, 360)

    ;auto

    GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
    Sleep($iSleep)
EndFunc   ;==>GraphicMain

Func a1()

    If $AA Then
        GUICtrlDelete($AA)
    EndIf
    $AA = GUICtrlCreateGraphic(0, 0, 400, 400)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 230, 220, 360, 360)
    ;yellow


    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFFff00)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 190, 80)
    ;Red

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xCD0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 10, 80)
    ;Blue

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x0000bb)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 280, 80)
    ;Green

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x008b00)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 100, 80)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 90, 360, 360)

    ;auto

    GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
    Sleep($iSleep)
    GraphicMain()
EndFunc   ;==>a1

Func a2()

    If $AA Then
        GUICtrlDelete($AA)
    EndIf
    $AA = GUICtrlCreateGraphic(0, 0, 400, 400)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 230, 220, 360, 360)
    ;yellow


    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFFD700)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 190, 80)
    ;Red

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFF0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 10, 80)
    ;Blue

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x0000bb)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 280, 80)
    ;Green

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x008b00)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 100, 80)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 90, 360, 360)

    ;auto

    GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
    Sleep($iSleep)
    GraphicMain()
EndFunc   ;==>a2

Func a3()

    If $AA Then
        GUICtrlDelete($AA)
    EndIf
    $AA = GUICtrlCreateGraphic(0, 0, 400, 400)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 230, 220, 360, 360)
    ;yellow


    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFFD700)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 190, 80)
    ;Red

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xCD0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 10, 80)
    ;Blue

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x1E90FF)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 280, 80)
    ;Green

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x008b00)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 100, 80)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 90, 360, 360)

    ;auto

    GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
    Sleep($iSleep)
    GraphicMain()
EndFunc   ;==>a3

Func a4()

    If $AA Then
        GUICtrlDelete($AA)
    EndIf

    $AA = GUICtrlCreateGraphic(0, 0, 400, 400)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 230, 220, 360, 360)
    ;yellow


    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFFD700)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 190, 80)
    ;Red

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xCD0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 10, 80)
    ;Blue

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x0000bb)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 280, 80)
    ;Green

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x00ff00)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 190, 100, 80)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0x000000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 224, 232, 90, 360, 360)

    ;auto

    GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)

    Sleep($iSleep)
    GraphicMain()
EndFunc   ;==>a4
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

That's overly complicated, I'm sure of it.

What's with the Pixel Checking?

Once a color it selected it checks value of the pattern against it and moves to the next pattern color. and Im sure its over complicated it was a shot in the dark with just a concept. still it came out good im happy with it.

[Cheeky]Comment[/Cheeky]
Link to comment
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
 Share

  • Recently Browsing   0 members

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