dirindon Posted April 15, 2010 Posted April 15, 2010 Well i am trying to make a simple game but dunno how to add function that will make you choose how many number's to guess also this code seems a bit messy. Would appreciate any help : )) expandcollapse popup; Moj script, by Dirindon. Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;Body of program; $o = 1 while $o = 1 $o = 2 MsgBox(64, "by Dirindon ", "Quite stupid game, try to remember the numbers thats appear from 1-9 and then write them in boxes.") MsgBox(64, "by Dirindon ", "to pause press Pause Break to terminate press ESC") $imie = InputBox("Heya", "Input your name please =]", "", " M8") $pp = 1 While $pp = 1 $pp = 0 $speed = InputBox("Heya", "Choose the number of second that box will appear for", "", " M1") $1 = random ( 1,9, 1) $2 = random ( 1,9, 1) $3 = random ( 1,9, 1) $4 = random ( 1,9, 1) $5 = random ( 1,9, 1) $6 = random ( 1,9, 1) MsgBox(0, "", " " & $1 , $speed ) MsgBox(0, "", " " & $2 , $speed ) MsgBox(0, "", " " & $3 , $speed ) MsgBox(0, "", " " & $4 , $speed ) MsgBox(0, "", " " & $5 , $speed ) MsgBox(0, "", " " & $6 , $speed ) $score = 0 Sleep( 1000 ) $v1 = InputBox("", "Write first number", "", " M1") if $v1 = $1 then $score = $score + 1 EndIf $v2 = InputBox("", "Second", "", " M1") if $v2 = $2 then $score = $score + 1 EndIf $v3 = InputBox("", "Third", "", " M1") if $v3 = $3 then $score = $score + 1 EndIf $v4 = InputBox("", "Next one!", "", " M1") if $v4 = $4 then $score = $score + 1 EndIf $v5 = InputBox("", "One more", "", " M1") if $v5 = $5 then $score = $score + 1 EndIf $v5 = InputBox("", "Last one", "", " M1") if $v5 = $5 then $score = $score + 1 Sleep ( 200 ) EndIf if $score = 6 Then msgbox (0, "Score!!!", "WTF PERFECT SCORE!! GRATZ " & $imie & " !!! Woot 6 / " & $score & " with the dissapear time of " & $speed ) EndIf if $score > 3 and $score < 4 then msgbox (0, "Score!", "Yea gratz i am impressed " & $imie & " of achiving score " & $score & " with the dissapear time of " & $speed ) EndIf if $score <3 Then msgbox (0, "Score", "You suck HARD " & $imie & " Your score is so lamme ... and its " & $score & " with dissapear time ... " & $speed ) EndIf $t = msgbox ( 4, "Hmm", "Do you wanna play again maybe ^^ ? ") if $t = 6 then $pp = 1 EndIf if $t = 7 Then $pp = 0 EndIf WEnd WEnd ;;;;;;;; Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('PAUZA', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() MsgBox(4096, "Exit", "Terminated by the User") Exit 0 EndFunc ;==>Terminate
Yoriz Posted April 15, 2010 Posted April 15, 2010 Made a few changes it will now ask how many question you want to be asked, theres no error checking to make sure numbers are entered and not letters. expandcollapse popup; Moj script, by Dirindon. Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") MsgBox(64, "by Dirindon ", "Quite stupid game, try to remember the numbers thats appear from 1-9 and then write them in boxes." & @CR & @CR & _ " To pause press Pause Break to terminate press ESC") $imie = InputBox("Heya", "Input your name please =]", "", " M8") Do $speed = InputBox("Heya", "Choose the number of second that box will appear for", "", " M1") $iAmountOfQuestions = InputBox("Hows Your memory", "Choose how many numbers to memorize") If $iAmountOfQuestions < 1 Then $iAmountOfQuestions = 1 ; stop you winning if you enter 0 Local $aRandomNo[$iAmountOfQuestions + 1], $score = 0 For $i = 1 To $iAmountOfQuestions Step 1 $aRandomNo[$i] = Random(1, 9, 1) MsgBox(0, "No =" & $i, " " & $aRandomNo[$i], $speed) Next Sleep(1000) For $i = 1 To $iAmountOfQuestions Step 1 $aAnswer = InputBox("", "Please enter No = " & $i, "", " M1") If $aAnswer = $aRandomNo[$i] Then $score += 1 Next $iScorePercent = ($score / $iAmountOfQuestions) * 100 Switch $iScorePercent Case 90 To 100 MsgBox(0, "Score!!!", "WTF PERFECT SCORE!! GRATZ " & $imie & " !!! Woot " & $iAmountOfQuestions & " / " & $score & ", with the dissapear time of " & $speed) Case 40 To 89 MsgBox(0, "Score!", "Yea gratz i am impressed " & $imie & " of achiving score of " & $score & " out of " & $iAmountOfQuestions & " questions, with the dissapear time of " & $speed) Case 0 To 39 MsgBox(0, "Score", "You suck HARD " & $imie & " Your score is so lamme ... and its " & $score & " with dissapear time ... " & $speed) EndSwitch $t = MsgBox(4, "Hmm", "Do you wanna play again maybe ^^ ? ") Until $t <> 6 Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('PAUZA', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() MsgBox(4096, "Exit", "Terminated by the User") Exit 0 EndFunc ;==>Terminate GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
dirindon Posted April 16, 2010 Author Posted April 16, 2010 (edited) Made a few changes it will now ask how many question you want to be asked, theres no error checking to make sure numbers are entered and not letters.Thank you very much it works much better now even % score i will learn a lot from this thank you very much for your help and very fast replay : )))I am also wondering if its possible to make appear msg boxes in random places and make it to choose if you want them appear random or not, becouse i didnt found anyt function to make msg box appear in the specified location . Thank you for help i am new to autoit. Edited April 16, 2010 by dirindon
l3ill Posted April 16, 2010 Posted April 16, 2010 Instead of msgbox try GUICreate, it gives you more control over timing and positioning and so forth... have fun! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
Yoriz Posted April 16, 2010 Posted April 16, 2010 If your not ready to start creating your own gui yet using 'GUICreate' as suggested above, instead of using msgbox you could have a try using SplashTextOn As you dont want any return from clicking a button this will work ok allowing you to set position and size and even font properties if you like, just use a sleep afterwards to control how long it is shown then remove it with SplashOff() Good luck GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now