I read somewhere that in game programming, you should always call isDead in every function |
You might be misinterpretting or taking it out of context.
You would want to check if the object is dead before assigning additional damage, or before enacting AI or something like that. But for polling the state of their health, there's no point.
Ask yourself this question:
Is the object's alive/dead state change whether or not they have full health?
If the answer is yes, then yeah, call isDead. If the answer is no, then don't.
Always be weary of "always do this" rules. People like to carve out rules like that, but in reality there are very very few of them.
Just use your head. Write code that makes sense.
EDIT:
Maybe what you meant is like... if determining whether or not the object has full health is a lengthy process...
1 2 3 4 5 6 7
|
bool isFullHealth()
{
if(isDead()) // if we're dead
return false; // then we obviously don't have full health!
// otherwise, do a much of crap here to determine whether or not we have full health
}
|