One thing that I never see people use is this.
- Code: Select all
result = (hp > 45);
in this case, if hp is greater than 45, then result will equal 1. Otherwise it will be 0.
We can write really nice functions with this.
- Code: Select all
int isMore(int one, int two)
{
return( one > two);
}
int isLess(int one, int two)
{
return (one < two);
}
int isEqual(int one, int two)
{
return (one == two);
}
or a whole bunch of other functions.
You can see that if and the comparison are not tied together. If is pretty useless without the comparison, but you can use the comparison in other places. In fact, you can do some other neat things with if, but I wont tell you. He is my enemy.