Jump to content
Sign in to follow this  
spootnick

Higher - Lower, game?

Recommended Posts

spootnick

Trying to make a "higher or Lower" Game,

I think most of you know this game.. what i have come up with so far is:

msgBox(4, "Roll of die", "Is your next card higher then : " & Random(1, 13, 1) )

But i need it to like "remember" the number and if the number is 6 and the next number is 7 and they pressed "no" , then it sould stop the game with a box saying "game over"

But i don't know how to make it like "see" what the number is, and then if they get it right they should move on with a new number..

Sorry for bad english, hope you guys will help me :mellow:

Kinda new for this.

Share this post


Link to post
Share on other sites
hannes08

Hey spootnick,

assign your Random() result to a variable, so you can use it several times.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites
GEOSoft

Please read the forum rules


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
LurchMan

Trying to make a "higher or Lower" Game,

I think most of you know this game.. what i have come up with so far is:

msgBox(4, "Roll of die", "Is your next card higher then : " & Random(1, 13, 1) )

But i need it to like "remember" the number and if the number is 6 and the next number is 7 and they pressed "no" , then it sould stop the game with a box saying "game over"

But i don't know how to make it like "see" what the number is, and then if they get it right they should move on with a new number..

Sorry for bad english, hope you guys will help me :mellow:

Kinda new for this.

Store the random number into a variable before you display it in the MsgBox like so:

$iStartNum = Random(1, 13, 1)
msgBox(4, "Roll of die", "Is your next card higher then : " & iStartNum )

GEOSoft - He's just building a game to learn AutoIt. This doesn't break the forum rules does it?

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
hannes08

Maybe you also want to read the helpfile regarding

Loops and Conditional Statements

(While ... Do; For To ... Next, If ... Then ... Else ... EndIf).

Or start by reading a tutorial. :mellow:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites
Blue_Drache

Please read the forum rules

Actually, he's building a game, I believe.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites
Valik

Actually, he's building a game, I believe.

This. Not locking.

Share this post


Link to post
Share on other sites
spootnick

Store the random number into a variable before you display it in the MsgBox like so:

$iStartNum = Random(1, 13, 1)
msgBox(4, "Roll of die", "Is your next card higher then : " & iStartNum )

GEOSoft - He's just building a game to learn AutoIt. This doesn't break the forum rules does it?

Okay, i understand that, but, when its a variable, its stores the number, until next time it use that variable, right?

But, what command can i use to see if the NEXT number is higher or lower then the last number?

Think this game is a little hard to start with, when i'm such a noob xD

But now im going to continue, hope you will help me :mellow:

Share this post


Link to post
Share on other sites
LurchMan

Okay, i understand that, but, when its a variable, its stores the number, until next time it use that variable, right?

But, what command can i use to see if the NEXT number is higher or lower then the last number?

Think this game is a little hard to start with, when i'm such a noob xD

But now im going to continue, hope you will help me :mellow:

I don't mind helping you. The variable will be that number until you change it. You can reference it at any time using an If statement or what ever you want to use.:

$var1 = 1
$var2 = 6
If $var1 > $var2 Then
     MsgBox (0, "$var1", "$var1 is greater!")
Else
     MsgBox (0, "$var1", "$var2 is greater!")
EndIf

Helpful hint: The help file (Press F1 in Scite) has very helpful tutorials to better explain all of this. There is also tons of simple source code that can be viewed in the Examples section of the forum.

Edit: This will help a lot too.

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
spootnick

so for making this game, i have to make 2 variables, so that it can get the:

If $var1 > $var2 Then     
 MsgBox (0, "$var1", "$var1 is greater!") 
Else      
MsgBox (0, "$var1", "$var2 is greater!")

??

Okay, i understand the making of variables, but what i don't understand is that, when i open the "game" it should give me a number, and ask if the next card is greater, if they press no, it sould come up with another random number, and tell if it was right or wrong.

i understand that first of all we need to get a random number, when they open the game by:

$roll = Random(1, 13, 1) 
MsgBox(4, "Higher or Lower", "Is your next card greater then: " $roll )

Then i have to somehow make a *if* they press "no" and the card is greater *then* it have to come up with another msgbox, and say game over,

*else*

just go again with a new random number.

Is what im saying correct or, totaly wrong? xD

Edited by spootnick

Share this post


Link to post
Share on other sites
JohnOne

Heres a very basic example to look over

$imax = 100 ;max random number
$imin = 1 ;mim random number

While 1
    $rnd = Random($imin, $imax, 1) ;create a random number between min amd max
    $equal = MsgBox(4, "Hmmmm", "Is Your Number " & $rnd) ;see if guessed correct
    If $equal = 6 Then ; guess was correct exit
        MsgBox(0, "Yay", "I Gueseed correct")
        Exit
    EndIf
    ;guess was not correct lets find out if it was higher or lower

    $higher = MsgBox(4, "Hmmmm", "Is Your Number Higher Than" & $rnd)
    If $higher = 6 Then 
        $imin = $rnd + 1 ;its higher, lets set out min random number to our first guess + 1
    Else
        $imax = $rnd - 1 ;its lower, lets set out max random number to our first guess - 1
    EndIf
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
spootnick

Heres a very basic example to look over

$imax = 100 ;max random number
$imin = 1 ;mim random number

While 1
    $rnd = Random($imin, $imax, 1) ;create a random number between min amd max
    $equal = MsgBox(4, "Hmmmm", "Is Your Number " & $rnd) ;see if guessed correct
    If $equal = 6 Then ; guess was correct exit
        MsgBox(0, "Yay", "I Gueseed correct")
        Exit
    EndIf
    ;guess was not correct lets find out if it was higher or lower

    $higher = MsgBox(4, "Hmmmm", "Is Your Number Higher Than" & $rnd)
    If $higher = 6 Then 
        $imin = $rnd + 1 ;its higher, lets set out min random number to our first guess + 1
    Else
        $imax = $rnd - 1 ;its lower, lets set out max random number to our first guess - 1
    EndIf
WEnd

Okay, that was not, the thing i was trying to make ..

Ehm the game is like this:

I open the game:

Is the next number greater then (random number) 5?

i press Yes

Next number is (random number) 11 (then it was correct)

Is the next number graeter then 11?

i press No

Next number i (random number) 13 (then it was NOT correct and should say Game Over)

Its as simpel as that.

Do you understand what i mean? :mellow:

Edited by spootnick

Share this post


Link to post
Share on other sites
bogQ

Heres a very basic example to look over

its example, not write it for me forum,

Do you understand what i mean? :mellow:


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
spootnick

$imax = 13 ;max random number
$imin = 1 ;mim random number
While 1
    $rnd = Random($imin, $imax, 1)
    $rnd2 = Random($imin, $imax, 1)
    $equal = MsgBox(4, "Higher - Lower", "Is the next number greater then: " & $rnd)
    If $equal = 6 Then 
        $rnd2 > $rnd ; if "yes" $rnd2 should be bigger then $rnd, if it is correct it should move on with a new number. if $rnd is bigger then $rnd2 its Gameover
        Else
    ElseIf
    WEnd

that is what i got..

i know how it should be made, but i don't know how to put it in the script.

:s this is hard..

Share this post


Link to post
Share on other sites
spootnick

Yes, I know, but what I have posted should give you enough information to get started with what you want.

Try look at what i just posted above ur post..

and see if it totaly out of the way :mellow:

Share this post


Link to post
Share on other sites
pieeater

@JohnOne

you have a typo.

$Correct = $rnd2 > $rnd

is what it should be.

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Share this post


Link to post
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
Sign in to follow this  

×