Coin flip

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
floogle11
Veteran
Posts: 71
Joined: Sat May 02, 2009 7:08 pm
Location: Zorgon planet
Contact:

Coin flip

Post by floogle11 »

Hey in this one game im making for fun theres a coin flip in the begging but its not working. I coded it like this.

Code:
input "Heads or tails?(H or T)"; horts$
randomize timer
num = int(rnd * 2) + 1
if horts$ = "H" or horts$ = "h" then
d = 1
b = 0
end if
if horts$ = "t" or horts$ ="T" then
b = 1
d = 0
end if
if num = 1 then d = d + 1
if num = 2 then b = b + 1
if b = d then goto Himfirst
if d > b then goto youfirst
'then the actual game.
Go to my Qbsite its: Trueqb.webs.com
Or if you play nazi zombies go to www.Nazizombys.com and register for cheats, hints, and strategys.
Anonymous

Post by Anonymous »

I tested your code and it seemed to work fine for me. Though I'm wondering why you are bothering to figure out which side the player pick it will still have the same probability. Something like this

Code: Select all

DO
INPUT "Heads or tails?(H or T)"; horts$
LOOP UNTIL (LCASE$(horts$) = "h" OR LCASE$(horts$) = "t")

RANDOMIZE TIMER
num = INT(RND * 2) + 1
IF num = 1 THEN GOTO Himfirst
IF num = 2 THEN GOTO youfirst
END

Himfirst:
PRINT "HIM"
END
youfirst:
PRINT "You"
User avatar
floogle11
Veteran
Posts: 71
Joined: Sat May 02, 2009 7:08 pm
Location: Zorgon planet
Contact:

Post by floogle11 »

hmm thats weird after i tested and it worked fine thanks anyway though
Go to my Qbsite its: Trueqb.webs.com
Or if you play nazi zombies go to www.Nazizombys.com and register for cheats, hints, and strategys.
Post Reply