GameObject enemy; bool available; // ... game code ... // check if enemy is dead if(enemy.isDead()) { available = false; // remove enemy from the game delete enemy; }
class Player { public: bool isDead() { return (health <= 0); } // ... other class methods ... private: int health; }; // ... game code ... Player player; if(player.isDead()) { // game over }This function is usually implemented as a member method of a game entity class or in a global utility function. It can be included in a game engine library package or in a separate game-specific library.