Jump to content
Sign in to follow this  
JustinReno

[Game] Match the Word Color

Recommended Posts

[Game]=(Match the word Color)=[Game]

I made a very simple game that follows the structure of a game by Mr.Bond007. Nothing is copied from his source so all credit goes to me.

Basically: Just click the button that the big button's word color corrusponds(I know that is spelled wrong) to. Sorry if the intructions are confusing, but its easy enough just to start the game and experiment(That might me spelled wrong too).

Please give feedback!

***Remember All credit goes to me except the game idea!***

#NoTrayIcon

Global $Data[6] = ["Blue", "Red", "Purple", "Orange", "Green", "Yellow"]
Global $Colors[6] = ["0x3299CC", "0xEE0000", "0x7D26CD", "0xFF6600", "0x308014", "0xFFFF00"]
Global $Color, $Time, $Level

Opt("GUIOnEventMode", 1)

$GUI = GUICreate("Match the word Color", 308, 90)
$ColorButton = GUICtrlCreateButton("", 0, 24, 75, 41, 0)
$Blue = GUICtrlCreateButton("Blue", 152, 0, 75, 25, 0)
$Red = GUICtrlCreateButton("Red", 152, 32, 75, 25, 0)
$Purple = GUICtrlCreateButton("Purple", 152, 64, 75, 25, 0)
$Orange = GUICtrlCreateButton("Orange", 232, 0, 75, 25, 0)
$Green = GUICtrlCreateButton("Green", 232, 32, 75, 25, 0)
$Yellow = GUICtrlCreateButton("Yellow", 232, 64, 75, 25, 0)
GUICtrlSetFont($ColorButton, 16)

_Color()

GUISetState(@SW_SHOW)

AdlibEnable("_Time", 1000)

GUISetOnEvent(-3, "_Check")
GUICtrlSetOnEvent($Blue, "_Check")
GUICtrlSetOnEvent($Red, "_Check")
GUICtrlSetOnEvent($Purple, "_Check")
GUICtrlSetOnEvent($Orange, "_Check")
GUICtrlSetOnEvent($Green, "_Check")
GUICtrlSetOnEvent($Yellow, "_Check")

While 1
WEnd

Func _Check()
    If @GUI_CtrlId = $Blue Then
        If $Colors[$Color] = 0x3299CC Then
            _Color()
        Else
            Beep(100, 100)
        EndIf
    EndIf
    If @GUI_CtrlId = $Red Then
        If $Colors[$Color] = 0xEE0000 Then
            _Color()
        Else
            Beep(100, 100)
        EndIf
    EndIf
    If @GUI_CtrlId = $Purple Then
        If $Colors[$Color] = 0x7D26CD Then
            _Color()
        Else
            Beep(100, 100)
        EndIf
    EndIf
    If @GUI_CtrlId = $Orange Then
        If $Colors[$Color] = 0xFF6600 Then
            _Color()
        Else
            Beep(100, 100)
        EndIf
    EndIf
    If @GUI_CtrlId = $Green Then
        If $Colors[$Color] = 0x308014 Then
            _Color()
        Else
            Beep(100, 100)
        EndIf
    EndIf
    If @GUI_CtrlId = $Yellow Then
        If $Colors[$Color] = 0xFFFF00 Then
            _Color()
        Else
            Beep(100, 100)
        EndIf
    EndIf
    If @GUI_CtrlId = -3 Then Exit
EndFunc   ;==>_Check

Func _Time()
    $Time -= 1
    WinSetTitle($GUI, "", "Match the word Color - " & $Time & "")
    If $Time = 0 Then
        MsgBox(64, "Match the word Color", "You lost on Level: " & $Level & "")
        Exit
    EndIf
EndFunc   ;==>_Time

Func _Color()
    $Color = Random(0, 5, 1)
    GUICtrlSetData($ColorButton, $Data[Random(0, 5, 1) ])
    GUICtrlSetColor($ColorButton, $Colors[$Color])
    $Time = 11
    $Level += 1
    If $Level >= 10 Then $Time = 6
    If $Level >= 20 Then $Time = 4
    If $Level > 25 Then $Time = 3
    If $Level = 30 Then
        MsgBox(64, "Click the color of the word", "Congrats " & @UserName & "! You won the last level 30! I hope you had fun!")
        Exit
    EndIf
EndFunc   ;==>_Color

Share this post


Link to post
Share on other sites

Only one of his "mini" games in the script. I'm making more that are not based off his. What do you think about it? Its also my first time using Gui(Ctrl)SetonEvent in my scripts. :)

Share this post


Link to post
Share on other sites

Only one of his "mini" games in the script. I'm making more that are not based off his. What do you think about it? Its also my first time using Gui(Ctrl)SetonEvent in my scripts. :)

Nice job at using GuiCtrlSetOnEvent... However this is really important. Now since you're using GuiSetOnEvent you're loop must contain a sleep! This script is taking 50% of my CPU and it would probably 0-1% if you had

While 1
Sleep(100)
WEnd

instead of

Whhile 1
WEnd

Share this post


Link to post
Share on other sites

Then it will be too unresponsive.

Anyways, I've been creating 3 more games. :)

With GuiOnEvent() you don't have unresponsive scripts (generally). I generally have a two second sleep time because the loop has absolutely no effect on the rest of the code aside from keeping the code going...

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...