Jump to content

A small game


Alek
 Share

Recommended Posts

here is a small memory game i made ^^,

Just click the correct button :D

Edit: More buttons ;)

Edit: Added Timer, if its enabled the you have 3sec to click on the next button :)

timer doesn't start until you press the first button.

#include <GUIConstants.au3>

Global $Button[10]
Global $Color_Low[10] = [0,0xaa0000,0x00aa00,0x0000aa,0xaaaa00,0xaa00aa,0x00aaaa,0xaa8800,0x6F3198,0xcccccc]
Global $Color_High[10] = [0,0xff0000,0x00ff00,0x0000ff,0xffff00,0xff00ff,0x00ffff,0xFFbb00,0xA163CA,0xffffff]
Global $Cur_Button
Global $Cur_Sequence
Global $Number
Global $Click_Timer

;Setings
Global $Enable_Timer = True

$Form1 = GUICreate("0-0", 150, 170, -1, -1)
$p = 1

GUISetState(@SW_SHOW)
For $y = 0 To 100 Step 50
    For $x = 0 To 100 Step 50
        $Button[$p] = GUICtrlCreateButton("", $x, $y, 50, 50, 0)
        _Blink($Button[$p],$Color_High[$p],$Color_Low[$p],50)
        $p += 1
    Next
Next

Sleep(1000)
_SetColors()

While 1
    $nMsg = GUIGetMsg()
    
    If $nMsg = $Button[$Number[$Cur_Button]] And (TimerDiff($Click_Timer) < 3000 Or $Click_Timer = 0)Then
        _Blink($Button[$Number[$Cur_Button]],$Color_High[$Number[$Cur_Button]],$Color_Low[$Number[$Cur_Button]],100)
        $Cur_Button += 1
        If $Enable_Timer Then $Click_Timer = TimerInit()
    ElseIf $nMsg = $GUI_EVENT_CLOSE Then
        Exit
    ElseIf $nMsg > 0 Or TimerDiff($Click_Timer) > 3000 And $Click_Timer > 0 Then
        WinSetTitle($Form1,'','Game Over!')
        For $x = 1 To 9
            GUICtrlSetBkColor($Button[$x],0x000000)
            Sleep(10)
        Next
        Sleep(1500)
        For $x = 1 To 9
            GUICtrlSetBkColor($Button[$x],$Color_Low[$x])
            Sleep(10)
        Next
        Sleep(500)
        $Cur_Sequence = ''
        _SetColors()
        $Click_Timer = 0
    EndIf
   
    If $Cur_Button > $Number[0] Then
        Sleep(1000)
        _SetColors()
    EndIf
WEnd

Func _SetColors()
    $Cur_Sequence &= Random(1,9,1)
    $Number = StringSplit($Cur_Sequence,'')
    WinSetTitle($Form1,'', 0 & '-' &  $Number[0])
    $Cur_Button = 1
    
    For $x = 1 To $Number[0]
        _Blink($Button[$Number[$x]],$Color_High[$Number[$x]],$Color_Low[$Number[$x]],200)
        Sleep(10)
    Next
    $Click_Timer = 0
    Return
EndFunc

Func _Blink($s_Ctrl,$s_Color1,$s_Color2,$s_Speed)
    GUICtrlSetBkColor($s_Ctrl,$s_Color1)
    Sleep($s_Speed)
    GUICtrlSetBkColor($s_Ctrl,$s_Color2)
    Sleep($s_Speed)
    Return
EndFunc

My Record: 19

Edited by Alek

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

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...