# Kids Learning Game

## Recommended Posts

Here is something my 4 year old came home with on a piece of paper from daycare. He really liked it, so I came up with this.

```;Find the number game
Opt("GUICloseOnESC", 0)
#include <GUIConstantsEx.au3>
#Include <Array.au3>
SRandom(Random(0, 254))
Dim \$aCorrect[8] = ["Good Job!", "That's Right!", "Way to Go!", "You're so smart!", "Very Good!", "There's no stopping you!", "Yep!", "Excelent!"]

;Populate an array from 1 - 20 2 times
Dim \$aNumbers[40]
\$j = 1
for \$i = 0 to 39
if \$j = 21 Then \$j = 1
\$aNumbers[\$i] = \$j
\$j += 1
Next
;Create the GUI controls
\$iGuiW = 370
\$iGuiH = 360
\$hGUIMain = GUICreate("Number Hunt", \$iGuiW, \$iGuiH)
Dim \$hNumbBtn[40]
\$iX = 10
\$iY = 10
For \$i = 0 to 39
\$iRand = Random(0, UBound(\$aNumbers) - 1, 1)
\$hNumbBtn[\$i] = GUICtrlCreateButton(\$aNumbers[\$iRand], \$iX, \$iY, 50, 40)
GUICtrlSetFont(-1, 16, 600)
GUICtrlSetState(-1, \$GUI_DISABLE)
\$iX += 60
if \$iX >= \$iGuiW - 50 Then
\$iY += 50
\$iX = 10
EndIf
_ArrayDelete(\$aNumbers, \$iRand)
Next
\$hStart = GUICtrlCreateButton("Start", \$iGuiW - 100, \$iGuiH - 40, 80, 25)
;Re-Populate the array from 1 - 20 2 times
Dim \$aNumbers[40]
\$j = 1
for \$i = 0 to 39
if \$j = 21 Then \$j = 1
\$aNumbers[\$i] = \$j
\$j += 1
Next

Dim \$oSp = ObjCreate("SAPI.SpVoice")
GUISetState(@SW_SHOW)
While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit
Case \$hStart
;Lock the gui control.
GUISetCursor(15, 1, \$hGUIMain)
GUISetState(@SW_DISABLE, \$hGUIMain)
for \$i = 0 to 39
GUICtrlSetState(\$hNumbBtn[\$i], \$GUI_ENABLE)
Next
\$iRand = Random(0, UBound(\$aNumbers) - 1, 1)
\$oSp.Speak("Can you find the number, " & \$aNumbers[\$iRand] & "?")
GUICtrlSetData(\$hStart, "Next")
;unlock the gui control
GUISetState(@SW_ENABLE, \$hGUIMain)
GUISetCursor(2, 1, \$hGUIMain)
EndSwitch
for \$i = 0 to 39
if \$nMsg = \$hNumbBtn[\$i] Then
;Lock the gui control.
GUISetCursor(15, 1, \$hGUIMain)
for \$l = 0 to 39
GUICtrlSetState(\$hNumbBtn[\$l], \$GUI_DISABLE)
Next
GUISetState(@SW_DISABLE, \$hGUIMain)
GUICtrlSetState(\$hNumbBtn[\$i], \$gui_hide)
if UBound(\$aNumbers) = 1 Then
\$oSp.Speak("You finished the game, Great Job!")
GUICtrlSetState(\$hStart, \$GUI_DISABLE)
EndIf
\$oSp.Speak(\$aCorrect[Random(0, UBound(\$aCorrect) - 1, 1)])
_ArrayDelete(\$aNumbers, \$iRand)
Else
\$oSp.Speak("Sorry, that's the number " & GUICtrlRead(\$hNumbBtn[\$i]))
\$oSp.Speak("Can you find the number, " & \$aNumbers[\$iRand] & "?")
for \$l = 0 to 39
GUICtrlSetState(\$hNumbBtn[\$l], \$GUI_ENABLE)
Next
EndIf
;unlock the gui control
GUISetState(@SW_ENABLE, \$hGUIMain)
GUISetCursor(2, 1, \$hGUIMain)
EndIf
Next
WEnd```

edit:

1. Updated with more success messages

2. Now locks the screen on each click, my Son got click happy which got the previous version stuck while he waited for the messages to finish.

Edited by MikeOsdx

hmm... I guess I have to have a signature...

##### Share on other sites

Good Game, but Microsoft Sam is scarey

I also notice on exit it doesn't make a new board to play again, and may be add some more random sayings instead of "Good Job" for everyone you get correct. just some idea's, but pretty neat anyways.

Edited by JellyFish666

##### Share on other sites

I like it.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

## Create an account

Register a new account