If you're nervous about depending on the exact return of a conditional, even if it is in the standard (every compiler is 100% adherent, right? =) ) you could just go ternary.
I'm not bashing the original version, but even if C doesn't have a separate true/false primitive I try to treat it that way... which would mean you don't add true + true + false.
If you really wanted to go nuts with ternary (not recommended this, there's just lots of ways to skin a cat):
You'll end up doing fewer operations when it's windy, but this is an eyesore.
-Lee
Code:
(velocity > 1)?1:0 + ...
I'm not bashing the original version, but even if C doesn't have a separate true/false primitive I try to treat it that way... which would mean you don't add true + true + false.
If you really wanted to go nuts with ternary (not recommended this, there's just lots of ways to skin a cat):
Code:
level = (velocity > 64)?5:
(velocity > 48)?4:
(velocity > 28)?3:
(velocity > 4)?2:
(velocity > 1)?1:0;
You'll end up doing fewer operations when it's windy, but this is an eyesore.
-Lee