Jump to content

My Game


Matu
 Share

Recommended Posts

Hi everyone, Ive just started using AUTOIT, and written a script for texted based game, using GUI's.

my problem is, since there's no GOTO command, I cant make my program re-start from the begining.

if anyone can help, please e-mail me, or edit the script posted

thanks

Matu

Link to comment
Share on other sites

This script restarts by using a varaible to keep count and a function to calculate and update the data in the label

#include <guiconstants.au3>
Global $button1, $counter = 0, $data1, $final, $form1, $label_1, $msg, $sum, $total

$form1 = GUICreate("GAME", 383, 208, 202, 131)
GUISetBkColor(0xffff00)
GUISetState(@SW_SHOW)
GUICtrlCreateLabel("THE MIND GAME", 70, 24, 261, 41)
GUICtrlSetFont(-1, 24, 400, 0, "ms sans serif")
$label_1 = GUICtrlCreateLabel("", 70, 100, 260, 21, 0x1000)
$button1 = GUICtrlCreateButton("OK", 130, 150, 130, 20)
GUICtrlSetColor(-1, 0xff00ff)
GUICtrlSetBkColor(-1, 0x000000)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $button1
            PlayFunction()
    EndSelect
WEnd

Exit

Func PlayFunction()
    GUICtrlSetState($button1, $GUI_DISABLE)
    Switch $counter
        Case 0
            $data1 = " THINK OF ANY NUMBER BETWEEN 10 - 1000"
        Case 1
            $data1 = " MULTIPLY THAT NUMBER BY 2"
        Case 2
            $total = (Random(1000))
            $final = (Round($total))
            If $final < 10 Then $final = 10
            $data1 = " NOW ADD    " & $final
        Case 3
            $data1 = " DIVIDE THAT NUMBER BY 2"
        Case 4
            $data1 = " SUBTRACT THAT NUMBER YOU THOUGHT OF"
        Case 5
            $sum = $final / 2
            $data1 = " YOUR FINAL ANSWER SHOULD BE  " & $sum
            $counter = 0
            GUICtrlSetData($label_1, $data1)
            GUICtrlSetState($button1, $GUI_ENABLE)
            Return
    EndSwitch
    $counter += 1
    GUICtrlSetData($label_1, $data1)
    GUICtrlSetState($button1, $GUI_ENABLE)
EndFunc

:P

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