Jump to content

A simple game


Alek
 Share

Recommended Posts

Its a very simple game.

based of a video i saw on youtube (

)

Just click on the buttons in order from 1 to 5 (default)

removed all the message boxs (boxs flash green when you make it and red when you fail, press the GO button to start)

Global Const $Freeze_Time = 500
Global Const $Level = 6

Global $Create_Numbers = True
Global $Positions[1][3]
Global $Cur_Button
Global $Button[$Level + 1]
Global $Round_Timer

For $x = 150 To @DesktopWidth - 150 Step 75
    For $y = 150 To  @DesktopHeight - 150 Step 75
        ReDim $Positions[UBound($Positions, 1) +1][3]
        $Positions[UBound($Positions, 1) -1][0] = $x
        $Positions[UBound($Positions, 1) -1][1] = $y
        $Positions[UBound($Positions, 1) -1][2] = False
    Next
Next

$Gui = GUICreate(\"\",@DesktopWidth-10,@DesktopHeight-5,0,0)
$Start_Button = GUICtrlCreateButton(\"Go\",0,0,75,75)
GUICtrlSetFont(-1, 40, 800)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetBkColor(0x000000)
For $x = 1 To $Level
    $Button[$x] = GUICtrlCreateButton(\"\", -75, -75, 75, 75)
    GUICtrlSetFont(-1, 40, 800)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
Next

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            ExitLoop
        Case $Start_Button
            For $x = 1 To UBound($Positions, 1) -1
                $Positions[$x][2] = False
            Next
            
            For $x = 1 To $Level
                Do
                    $Random = Random(1, UBound($Positions, 1) -1, 1)
                Until Not $Positions[$Random][2]
                $Positions[$Random][2] = True
                GUICtrlSetPos($Button[$x],$Positions[$Random][0],$Positions[$Random][1])
            Next
            
            For $x = 1 To $Level
                GUICtrlSetData($Button[$x], $x)
            Next
            
            Sleep($Freeze_Time)
            For $x = 1 To $Level
                GUICtrlSetData($Button[$x], \"\")
            Next
            
            $Round_Timer = TimerInit()
            $Cur_Button = 1
            $Create_Numbers = False
            $Msg = 0
    EndSwitch
    
    If $Msg > 0 And $Cur_Button < UBound($Button) And $Msg = $Button[$Cur_Button]  And Not $Create_Numbers  Then
        GUICtrlSetData($Button[$Cur_Button], $Cur_Button)
        $Cur_Button += 1
        If $Cur_Button > $Level Then
            For $x = 1 To $Level
                GUICtrlSetData($Button[$x], $x)
                GUICtrlSetBkColor($Button[$x], 0x00ff00)
            Next
            Sleep(1000)
            For $x = 1 To $Level
                GUICtrlSetData($Button[$x], $x)
                GUICtrlSetBkColor($Button[$x], 0xFFFFFF)
            Next
            $Create_Numbers = True
            WinSetTitle($Gui, \"\", \"You did it in only \" & Round(TimerDiff($Round_Timer),0) & \"ms :D\")
        EndIf
    ElseIf  Not $Create_Numbers And $Msg < $Button[$Cur_Button] Then
        ;simple way to avoid causing problems when user press 1 of the buttons he has already pressed :)
    ElseIf $Msg > 0 And Not $Create_Numbers And $Msg <> $Button[$Cur_Button] Then
        For $x = 1 To $Level
            GUICtrlSetData($Button[$x], $x)
            GUICtrlSetBkColor($Button[$x], 0xff0000)
        Next
        Sleep(1000)
        For $x = 1 To $Level
            GUICtrlSetData($Button[$x], $x)
            GUICtrlSetBkColor($Button[$x], 0xFFFFFF)
        Next
        $Create_Numbers = True
    EndIf
    
WEnd
Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

Nice work on this..

Just a question about this game, how do you (anyone) remember the order? I find one and then form path going to 2 and then to 3 ... to 5. Generally I find out where a few other numbers are on the way to finding 1 so I skip actually placing those in my path until the numbers disappear. For example, if there's a 2 and 3 on top I see those first and then find a one in the middle, so I now have the position of 1 in my mind while vaguely remembering where 2 and 3 are, I then find four and five. Then the numbers disappear and I add the 2 and 3 into my visualization of the path.

Edited by Achilles
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
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...