Page 1 of 1

How to code heads or tails?

PostPosted: 05 Nov 2015, 01:40
by Rockenchick
How would one code a coin flip result for whether it's heads or tails, rather than win or lose? I looked a bit and it seems either the tail and heads themselves are assigned the number 0 or 1 or extra code would need to added to do so. So, if the game already considers each to be assigned a value of 0 or 1 then the result could be defined as that number without adding extra conditions (thereby replacing WIN or LOSE with said number), or am I totally off on this?

How would one code it so that all players flipped a coin at the same time, rather than just 1 player or less than all the players? I've seen different ways of determining that each player does something simultaneously but not in regards to flipping a coin.

I'm looking at making Goblin Assassin and those parts just really confused me.

Re: How to code heads or tails?

PostPosted: 05 Nov 2015, 01:59
by Xander9009
"Lose" and "tails" are the same thing. When a coin is flipped, the result is a 0 or a 1 like you said. There happen to be two handy constants for comparing the results: COIN_FLIP_LOSE and COIN_FLIP_WIN. But that's all they are, constants, variables, just like any other variable you could name and set. Heads is 1 and tails is 0, COIN_FLIP_WIN is 1 and COIN_FLIP_LOSE is 0. So, tails and COIN_FLIP_LOSE are the same thing.