Jump to content

A simple "Yes/No" Game


Fubb
 Share

Recommended Posts

here is an example of a gui version, you can do almost anything with gui's......... KODA is also pretty good but personally i prefer making it from scratch because i dunno it feels more personal (THIS IS AN EXAMPLE) only one version of a gui you can make

#include<Guiconstants.au3.>
#include<ButtonConstants.au3>
#Include<WindowsConstants.au3>
#Include<StaticConstants.au3>

OPT('GUIoneventmode',1)

$GUI = guicreate('EXAMPLE',300,100)
guisetonevent($GUI_EVENT_CLOSE,'_EXIT',$GUI)

$Label = guictrlcreatelabel('Whatever you want.',10,10,300,70)

$Button_Yes = guictrlcreatebutton('Yes',5,70,140,20)
guictrlsetonevent($Button_Yes,'Yes')

$Button_No = guictrlcreatebutton('No',150,70,140,20)
guictrlsetonevent($Button_No,'No')

GUIsetstate(@SW_SHOW)

While 1
wend

Func No()
If GUICtrlRead($Label) = 'Whatever you want.' Then 
    GUICtrlSetData($Label,'youve hit "No" This is question #2.')
ElseIf GUICtrlRead($Label) = 'youve hit "No" This is question #2.' Then 
    GUICtrlSetData($Label,'youve hit "No" This is question #3.')
ElseIf GUICtrlRead($Label) = 'youve hit "Yes" This is question #2.' Then 
    GUICtrlSetData($Label,'youve hit "No" This is question #3.')
;ect.........
EndIf
EndFunc

Func Yes()
If GUICtrlRead($Label) = 'Whatever you want.' Then 
    GUICtrlSetData($Label,'youve hit "Yes" This is question #2.')
ElseIf GUICtrlRead($Label) = 'youve hit "Yes" This is question #2.' Then 
    GUICtrlSetData($Label,'youve hit "Yes" This is question #3.')
ElseIf GUICtrlRead($Label) = 'youve hit "No" This is question #2.' Then 
    GUICtrlSetData($Label,'youve hit "Yes" This is question #3.')
;ect.........
EndIf
EndFunc

Func _EXIT()
    Exit
EndFunc
Edited by CodyBarrett
Link to comment
Share on other sites

I live by KODA, it is great. Designing forums for you is awesome. It is completely WYSIWYG based saving lots of time unless you have the form codes completely memorized like the back of your hand. Also, you don't have to worry about errors in the script.

If you don't have the full version of SciTE which includes KODA form designer, i highly recommend you download it. It is a great resource and development tool.

...will never learn all there is to know about autoit, no worries...i came to the forums :)

Link to comment
Share on other sites

hey what u can do is this.. just create a simple GUI with a label.. 2 YES/NO buttons.. depending on the YES/NO, u just create the text of the label by ControlSetText.. simple and easy.. use if conditions.. to decide what text to display next..

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

This is my take on it using arrays.

;Current question
Global $iCurrentQuestion = 1

Global $aQuestions[10][3]
;Set up as follows
; [0][0] = Total (Set automatically)
; [n][0] = Question
; [n][1] = Yes question
; [n][2] = No question

;Total number of questions
$aQuestions[0][0] = UBound ($aQuestions)-1;Just in case we need to use it!

;Set the questions!

;Question 1
$aQuestions[1][0] = "This is the first question." & @CRLF & "I want to know if you are male or female.  Are you male?"
$aQuestions[1][1] = 2
$aQuestions[1][2] = 3
;Question 2
$aQuestions[2][0] = "Now that I know you are male, I want to know your age." & @CRLF & "Are you under 30?"
$aQuestions[2][1] = 4
$aQuestions[2][2] = 5
;Question 3
$aQuestions[3][0] = "Now that I know you are female, I want to know your hairstyle." & @CRLF & "Is your hair long?"
$aQuestions[3][1] = 6
$aQuestions[3][2] = 7
;Question 4
$aQuestions[4][0] = "So you are under 30?  We'll soon find out if you're telling a little lie..." & @CRLF & "Do you know who Robert Pattinson is?"
$aQuestions[4][1] = 8
$aQuestions[4][2] = 9
;Question 5
$aQuestions[5][0] = "You're over 30?  Very intresting!" & @CRLF & "This is the end of the game, but press no to test out of bounds array checking...!"
$aQuestions[5][1] = -1
$aQuestions[5][2] = 50
;Question 6
$aQuestions[6][0] = "Long hair... Me likes!" & @CRLF & "This is the end of my game... I hope you had fun!"
$aQuestions[6][1] = -1
$aQuestions[6][2] = -2
;Question 7
$aQuestions[7][0] = "Short hair aye... Looks good!" & @CRLF & "This is the end of my game... I hope you had fun!"
$aQuestions[7][1] = -1
$aQuestions[7][2] = -2
;Question 8
$aQuestions[8][0] = "Well you mustn't be male, cause hes a female idol... Are you sure you didn't google him?" & @CRLF & "This is the end of my game... I hope you had fun!"
$aQuestions[8][1] = -1
$aQuestions[8][2] = -2
;Question 9
$aQuestions[9][0] = "Neither do I.... Not that it matters!" & @CRLF & "This is the end of my game... I hope you had fun!"
$aQuestions[9][1] = -1
$aQuestions[9][2] = -2

;While loop
While 1
;Ask question
    $iQuestion = MsgBox(4, "Quick Quiz", $aQuestions[$iCurrentQuestion][0])
;Check what was returned...  if yes set the question to be what we want, do the same for no...
    If $iQuestion = 6 Then;Yes
        $iCurrentQuestion = $aQuestions[$iCurrentQuestion][1]
    ElseIf $iQuestion = 7 Then; No
        $iCurrentQuestion = $aQuestions[$iCurrentQuestion][2]
    EndIf
;Just in case we stuffed up, check that the question is right for the array....
    If $iCurrentQuestion > $aQuestions[0][0] Then
        MsgBox (0, "ERROR", "Array out of bounds.  Exiting...")
        Exit
    EndIf
    
;Just check for special cases, exit and the like
    Switch $iCurrentQuestion
        Case - 1
            Exit
        Case -2
            MsgBox (0, "OMGZ!", "You didn't have fun!  Fine... I'll go home and cry...")
            Exit
    EndSwitch
WEnd

It can be expanded fairly easily just by adding certain elements into the array etc... :)

Cheers,

Brett

EDIT: And that reminds me... HOLY CRAP! It is so hard to understand most of you! My dog makes more sense than you are. So please make the effort to spell check, check your grammar and type proper and full sentences. In other words legible English!

Edited by BrettF
Link to comment
Share on other sites

Our new computer didn't come in, so...yes, Still have to wait...

:)

Current Projects:"Cuban Missile Crisis" Decisions Game, -----------------------------------------------"I have got a lovely bunch of Coconust""Nuts*""Damn the songs ruined now" ~TheChosen

Link to comment
Share on other sites

Fubb that sucks, and brett this is probably why i basically failed LA.. i appologize :)

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