• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Comparing 3 or more variables.

D

D God of Mind D

Guest
Hello, guys. I didn't found any info about it, so I ask it here.
I have character, which can gaim genetic points of 3 types: red_gene, blue_gene, green_gene.

I need to compare all three variables to find the highest of them in case to change color of the sprite to relative one. I know how to find highest variable between two, it's just if (red_gene < blue_gene). But I don't know how to do it with 3 or more variables.
 
D

D God of Mind D

Guest
Well, nvm. I found the solution. Can close the thread.
 

Bentley

Member
Edit: nevermind, haha, literally the second after I posted you posted saying that you answered your own question.
Code:
var highest = max(red_gene, green_gene, blue_gene);
 

Slyddar

Member
If you want the biggest or smallest, you can just use min and max.
Code:
var highest = max(red_gene, blue_gene, green_gene);
EDIT: Beaten with an almost identical answer :p
 

Bentley

Member
If you want the biggest or smallest, you can just use min and max.
Code:
var highest = max(red_gene, blue_gene, green_gene);
EDIT: Beaten with an almost identical answer :p
Haha, and I was beaten by the poster answering his own question : )
 

Bentley

Member
Haha, and I was beaten by the poster answering his own question : )
You know what's funny also is that our post would have been identical but I thought to myself, "well, the order is RGB whenever talking about colors, so even the poster did it red_gene, blue_gene, green_gene, I'll do it red_gene, green_gene, blue_gene".

Ok, enough of my palavering (love that word).
 
Top