Jump to content

Kids Learning Game


BigDaddyO
 Share

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)
            if GUICtrlRead($hNumbBtn[$i]) = $aNumbers[$iRand] Then
                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
Link to comment
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
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...