It is currently 16 Apr 2024, 20:36
   
Text Size

How to code heads or tails?

Moderator: CCGHQ Admins

How to code heads or tails?

Postby Rockenchick » 05 Nov 2015, 01:40

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.
Last edited by Rockenchick on 05 Nov 2015, 02:02, edited 1 time in total.
Rockenchick
 
Posts: 21
Joined: 16 Oct 2015, 05:05
Has thanked: 4 times
Been thanked: 2 times

Re: How to code heads or tails?

Postby Xander9009 » 05 Nov 2015, 01:59

"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.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 12 guests


Who is online

In total there are 12 users online :: 0 registered, 0 hidden and 12 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 12 guests

Login Form